diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-07-30 20:42:02 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-07-30 20:42:02 +1200 |
commit | 110c49504f87c025423c923500bd52ea4615b33b (patch) | |
tree | 2398fd3fa3286b35b6f80cad51b59703d3065b6e /src/org/traccar/ServerManager.java | |
parent | 5f75f109dfc1140d2f644857d877baf88cb1fe83 (diff) | |
download | traccar-server-110c49504f87c025423c923500bd52ea4615b33b.tar.gz traccar-server-110c49504f87c025423c923500bd52ea4615b33b.tar.bz2 traccar-server-110c49504f87c025423c923500bd52ea4615b33b.zip |
Improve logging system (fix #278)
Diffstat (limited to 'src/org/traccar/ServerManager.java')
-rw-r--r-- | src/org/traccar/ServerManager.java | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index 61bf55616..a32a49572 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -89,9 +89,6 @@ public class ServerManager { return properties; } - /** - * Initialize - */ public void init(String[] arguments) throws IOException, ClassNotFoundException, SQLException { @@ -103,7 +100,7 @@ public class ServerManager { dataManager = new DatabaseDataManager(properties); - initLogger(properties); + Log.setupLogger(properties); initGeocoder(properties); initXexunServer("xexun"); @@ -159,9 +156,6 @@ public class ServerManager { } } - /** - * Start - */ public void start() { if (webServer != null) { webServer.start(); @@ -171,9 +165,6 @@ public class ServerManager { } } - /** - * Stop - */ public void stop() { for (Object server: serverList) { ((TrackerServer) server).stop(); @@ -188,57 +179,10 @@ public class ServerManager { } } - /** - * Destroy - */ public void destroy() { serverList.clear(); } - /** - * Initialize logger - */ - private void initLogger(Properties properties) throws IOException { - - loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable")); - - if (loggerEnabled) { - - String fileName = properties.getProperty("logger.file"); - if (fileName != null) { - - FileHandler file = new FileHandler(fileName, true); - - // Simple formatter - file.setFormatter(new Formatter() { - private final String LINE_SEPARATOR = - System.getProperty("line.separator", "\n"); - - private final DateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - @Override - public String format(LogRecord record) { - StringBuffer line = new StringBuffer(); - dateFormat.format(new Date(record.getMillis()), line, new FieldPosition(0)); - line.append(" "); - line.append(record.getSourceClassName()); - line.append("."); - line.append(record.getSourceMethodName()); - line.append(" "); - line.append(record.getLevel().getName()); - line.append(": "); - line.append(formatMessage(record)); - line.append(LINE_SEPARATOR); - return line.toString(); - } - }); - - Log.getLogger().addHandler(file); - } - } - } - private void initGeocoder(Properties properties) throws IOException { if (Boolean.parseBoolean(properties.getProperty("geocoder.enable"))) { reverseGeocoder = new GoogleReverseGeocoder(); |