diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-14 14:33:49 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2018-09-14 14:33:49 +1200 |
commit | b10824bb5769c4abb93e3451673b88efdfb9d467 (patch) | |
tree | c4d04ed2f19d5758a75b702467dbc051c5d0511c /src/org/traccar/Main.java | |
parent | e331573c0df7467fd36ae3eba3c259ed9b1d9253 (diff) | |
download | trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.gz trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.tar.bz2 trackermap-server-b10824bb5769c4abb93e3451673b88efdfb9d467.zip |
Log using slf4j and java logging
Diffstat (limited to 'src/org/traccar/Main.java')
-rw-r--r-- | src/org/traccar/Main.java | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java index 1e2db2693..fd1f07dca 100644 --- a/src/org/traccar/Main.java +++ b/src/org/traccar/Main.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2015 Anton Tananaev (anton@traccar.org) + * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,14 @@ */ package org.traccar; -import org.traccar.helper.Log; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.lang.management.ManagementFactory; +import java.lang.management.MemoryMXBean; +import java.lang.management.OperatingSystemMXBean; +import java.lang.management.RuntimeMXBean; +import java.nio.charset.Charset; import java.sql.SQLException; import java.util.Timer; import java.util.TimerTask; @@ -24,16 +30,47 @@ import java.util.Locale; public final class Main { + private static final Logger LOGGER = LoggerFactory.getLogger(Main.class); + private static final long CLEAN_PERIOD = 24 * 60 * 60 * 1000; private Main() { } + public static void logSystemInfo() { + try { + OperatingSystemMXBean operatingSystemBean = ManagementFactory.getOperatingSystemMXBean(); + LOGGER.info("Operating system" + + " name: " + operatingSystemBean.getName() + + " version: " + operatingSystemBean.getVersion() + + " architecture: " + operatingSystemBean.getArch()); + + RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); + LOGGER.info("Java runtime" + + " name: " + runtimeBean.getVmName() + + " vendor: " + runtimeBean.getVmVendor() + + " version: " + runtimeBean.getVmVersion()); + + MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); + LOGGER.info("Memory limit" + + " heap: " + memoryBean.getHeapMemoryUsage().getMax() / (1024 * 1024) + "mb" + + " non-heap: " + memoryBean.getNonHeapMemoryUsage().getMax() / (1024 * 1024) + "mb"); + + LOGGER.info("Character encoding: " + + System.getProperty("file.encoding") + " charset: " + Charset.defaultCharset()); + + } catch (Exception error) { + LOGGER.warn("Failed to get system info"); + } + } + public static void main(String[] args) throws Exception { Locale.setDefault(Locale.ENGLISH); Context.init(args); - Log.info("Starting server..."); + logSystemInfo(); + LOGGER.info("Version: " + Context.getAppVersion()); + LOGGER.info("Starting server..."); Context.getServerManager().start(); if (Context.getWebServer() != null) { @@ -46,7 +83,7 @@ public final class Main { try { Context.getDataManager().clearHistory(); } catch (SQLException error) { - Log.warning(error); + LOGGER.warn(null, error); } } }, 0, CLEAN_PERIOD); @@ -54,7 +91,7 @@ public final class Main { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - Log.info("Shutting down server..."); + LOGGER.info("Shutting down server..."); if (Context.getWebServer() != null) { Context.getWebServer().stop(); |