Migrated logging to log4j2 and adapted java.util.logging to log4j.
Change-Id: I587a8f0252714e17ec70e0f9eb5db63aca292b5f
diff --git a/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java b/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
index 90673e1..192d257 100644
--- a/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
+++ b/lite/src/main/java/de/ids_mannheim/korap/web/service/lite/LiteService.java
@@ -17,8 +17,8 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -55,7 +55,7 @@
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class LiteService {
- private static Logger jlog = LoggerFactory.getLogger(LiteService.class);
+ private static Logger jlog = LogManager.getLogger(LiteService.class);
@Autowired
CoreResponseHandler kustvaktResponseHandler;
@@ -145,10 +145,10 @@
throw kustvaktResponseHandler.throwit(e);
}
// todo: should be possible to add the meta part to the query serialization
- jlog.info("Serialized search: {}", jsonld);
+ jlog.info("Serialized search: "+jsonld);
try {
String result = searchKrill.search(jsonld);
- jlog.debug("The result set: {}", result);
+ jlog.debug("The result set: "+result);
return Response.ok(result).build();
}
catch (Exception e) {
@@ -188,7 +188,7 @@
catch (KustvaktException e) {
throw kustvaktResponseHandler.throwit(e);
}
- jlog.info("the serialized query {}", query);
+ jlog.info("the serialized query "+ query);
// This may not work with the the KoralQuery
if (eng.equals(KustvaktConfiguration.BACKENDS.NEO4J)) {
@@ -209,7 +209,7 @@
}
else
result = searchKrill.search(query);
- jlog.debug("The result set: {}", result);
+ jlog.debug("The result set: "+ result);
return Response.ok(result).build();
}
@@ -290,7 +290,7 @@
throw kustvaktResponseHandler.throwit(500, e.getMessage(), null);
}
- jlog.debug("The result set: {}", result);
+ jlog.debug("The result set: "+ result);
return Response.ok(result).build();
}
diff --git a/lite/src/main/resources/log4j.properties b/lite/src/main/resources/log4j.properties
deleted file mode 100644
index 5d769fb..0000000
--- a/lite/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-
-# Root logger option
-#log4j.threshold=ALL
-log4j.rootLogger=error, stdout, debugLog
-log4j.logger.log=ERROR, errorLog
-
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
-
-log4j.appender.errorLog=org.apache.log4j.RollingFileAppender
-log4j.appender.errorLog.layout=org.apache.log4j.PatternLayout
-log4j.appender.errorLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
-log4j.appender.errorLog.File=./logs/errors.log
-
-log4j.appender.policyLog=org.apache.log4j.RollingFileAppender
-log4j.appender.policyLog.layout=org.apache.log4j.PatternLayout
-log4j.appender.policyLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
-log4j.appender.policyLog.File=./logs/policies.log
-
-log4j.appender.authLog=org.apache.log4j.RollingFileAppender
-log4j.appender.authLog.layout=org.apache.log4j.PatternLayout
-log4j.appender.authLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
-log4j.appender.authLog.File=./logs/auth.log
-
-log4j.appender.debugLog=org.apache.log4j.RollingFileAppender
-log4j.appender.debugLog.layout=org.apache.log4j.PatternLayout
-log4j.appender.debugLog.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %C{6} - %M %n %-5p: %m%n
-log4j.appender.debugLog.File=./logs/logging.log
-
-
-log4j.logger.de.ids_mannheim.korap.security.ac = ERROR, policyLog
-log4j.logger.de.ids_mannheim.korap.security.auth = ERROR, authLog
\ No newline at end of file
diff --git a/lite/src/main/resources/log4j2.properties b/lite/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..6692040
--- /dev/null
+++ b/lite/src/main/resources/log4j2.properties
@@ -0,0 +1,21 @@
+appenders = console, file
+appender.console.type = Console
+appender.console.name = STDOUT
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+
+appender.file.type = File
+appender.file.name = ERRORLOG
+appender.file.fileName=./logs/errors.log
+appender.file.layout.type=PatternLayout
+appender.file.layout.pattern= %d{yyyy-MM-dd, HH:mm:ss} %C{6} - %M%n %-5p: %m%n
+
+rootLogger.level = error
+rootLogger.appenderRefs = stdout
+rootLogger.appenderRef.stdout.ref = STDOUT
+
+#loggers=file
+#logger.file.name=de.ids_mannheim.korap
+#logger.file.level = error
+#logger.file.appenderRefs = file
+#logger.file.appenderRef.file.ref = ERRORLOG
\ No newline at end of file