aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-08-23 21:00:09 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-08-23 21:00:09 +1200
commit63d1859cde9c8f3fb9bc85e0c202750bda8d975e (patch)
tree7564fa5419f14d72a9853f52f7b76dbaf101e5c2 /src
parentcaa4fd747981075ed47315fffc5bbd18268278bd (diff)
downloadtraccar-server-63d1859cde9c8f3fb9bc85e0c202750bda8d975e.tar.gz
traccar-server-63d1859cde9c8f3fb9bc85e0c202750bda8d975e.tar.bz2
traccar-server-63d1859cde9c8f3fb9bc85e0c202750bda8d975e.zip
Netty logger implementation
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/Main.java9
-rw-r--r--src/org/traccar/ServerManager.java4
-rw-r--r--src/org/traccar/helper/Log.java76
3 files changed, 78 insertions, 11 deletions
diff --git a/src/org/traccar/Main.java b/src/org/traccar/Main.java
index 0e29dcb59..144ad1ec7 100644
--- a/src/org/traccar/Main.java
+++ b/src/org/traccar/Main.java
@@ -20,8 +20,6 @@ import java.lang.management.MemoryMXBean;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.RuntimeMXBean;
import java.util.Locale;
-import org.jboss.netty.logging.InternalLoggerFactory;
-import org.jboss.netty.logging.Log4JLoggerFactory;
import org.traccar.helper.Log;
public class Main {
@@ -49,13 +47,6 @@ public class Main {
}
}
- /**
- * Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem"
- */
- static {
- InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
- }
-
public static void main(String[] args) throws Exception {
Locale.setDefault(Locale.ENGLISH);
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index 2e5dfcda5..6216da225 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -91,14 +91,14 @@ public class ServerManager {
properties.loadFromXML(new FileInputStream(arguments[0]));
}
- dataManager = new DatabaseDataManager(properties);
-
// Init logger
loggerEnabled = Boolean.valueOf(properties.getProperty("logger.enable"));
if (loggerEnabled) {
Log.setupLogger(properties);
}
+ dataManager = new DatabaseDataManager(properties);
+
initGeocoder(properties);
initXexunServer("xexun");
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index 3c173f71e..d14a7b0bb 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -24,6 +24,9 @@ import org.apache.log4j.Level;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
+import org.jboss.netty.logging.AbstractInternalLogger;
+import org.jboss.netty.logging.InternalLogger;
+import org.jboss.netty.logging.InternalLoggerFactory;
public class Log {
@@ -42,6 +45,14 @@ public class Log {
logger = Logger.getLogger(LOGGER_NAME);
logger.addAppender(appender);
logger.setLevel(Level.ALL);
+
+ // Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem"
+ InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() {
+ @Override
+ public InternalLogger newInstance(String string) {
+ return new NettyInternalLogger();
+ }
+ });
}
public static Logger getLogger() {
@@ -97,4 +108,69 @@ public class Log {
getLogger().debug(msg);
}
+ /**
+ * Netty logger implementation
+ */
+ private static class NettyInternalLogger extends AbstractInternalLogger {
+
+ @Override
+ public boolean isDebugEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return false;
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return true;
+ }
+
+ @Override
+ public void debug(String string) {
+ debug(string, null);
+ }
+
+ @Override
+ public void debug(String string, Throwable thrwbl) {
+ }
+
+ @Override
+ public void info(String string) {
+ info(string, null);
+ }
+
+ @Override
+ public void info(String string, Throwable thrwbl) {
+ }
+
+ @Override
+ public void warn(String string) {
+ warn(string, null);
+ }
+
+ @Override
+ public void warn(String string, Throwable thrwbl) {
+ getLogger().warn("netty warning: " + string);
+ }
+
+ @Override
+ public void error(String string) {
+ error(string, null);
+ }
+
+ @Override
+ public void error(String string, Throwable thrwbl) {
+ getLogger().error("netty error: " + string);
+ }
+
+ }
+
}