From 569ee68a9219a33c2a4bdd2bc43dd4f8e8cdfed4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 20 Aug 2013 20:18:21 +1200 Subject: Fix packet logging --- src/org/traccar/BasePipelineFactory.java | 3 +-- src/org/traccar/ServerManager.java | 9 +++++++-- src/org/traccar/helper/Log.java | 17 +++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java index e5aa5f76b..9d2ab5071 100644 --- a/src/org/traccar/BasePipelineFactory.java +++ b/src/org/traccar/BasePipelineFactory.java @@ -70,9 +70,8 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory { // Append hex message if (event.getMessage() instanceof ChannelBuffer) { - msg.append(" - (HEX: "); + msg.append(" - HEX: "); msg.append(ChannelBuffers.hexDump((ChannelBuffer) event.getMessage())); - msg.append(")"); } Log.debug(msg.toString()); diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java index e478c6f2f..95f8c7b58 100644 --- a/src/org/traccar/ServerManager.java +++ b/src/org/traccar/ServerManager.java @@ -93,7 +93,12 @@ public class ServerManager { dataManager = new DatabaseDataManager(properties); - Log.setupLogger(properties); + // Init logger + loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable")); + if (loggerEnabled) { + Log.setupLogger(properties); + } + initGeocoder(properties); initXexunServer("xexun"); @@ -151,7 +156,7 @@ public class ServerManager { initGatorServer("gator"); initNoranServer("noran"); initM2mServer("m2m"); - + // Initialize web server if (Boolean.valueOf(properties.getProperty("http.enable"))) { webServer = new WebServer(properties); diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java index f79fce79d..3c173f71e 100644 --- a/src/org/traccar/helper/Log.java +++ b/src/org/traccar/helper/Log.java @@ -32,19 +32,16 @@ public class Log { private static Logger logger = null; public static void setupLogger(Properties properties) throws IOException { - if (Boolean.valueOf(properties.getProperty("logger.enable"))) { - Layout layout = new PatternLayout( - "%d{yyyy-MM-dd HH:mm:ss} %5p: %m%n"); + Layout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %5p: %m%n"); - Appender appender = new DailyRollingFileAppender( - layout, properties.getProperty("logger.file"), "'.'yyyyMMdd"); + Appender appender = new DailyRollingFileAppender( + layout, properties.getProperty("logger.file"), "'.'yyyyMMdd"); - LogManager.resetConfiguration(); - logger = Logger.getLogger(LOGGER_NAME); - logger.addAppender(appender); - logger.setLevel(Level.DEBUG); - } + LogManager.resetConfiguration(); + logger = Logger.getLogger(LOGGER_NAME); + logger.addAppender(appender); + logger.setLevel(Level.ALL); } public static Logger getLogger() { -- cgit v1.2.3