summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2021-12-16 12:58:44 +0100
committerManuel Bentele2021-12-16 12:58:44 +0100
commit96b0f232f1fcb4b48a72dbe96f01270a09d4cf70 (patch)
treeb22ee34dd249424e4c77cebf8c40d30bf5788d44
parent[api] Update version of gson dependency (diff)
downloadtaskman-lite-96b0f232f1fcb4b48a72dbe96f01270a09d4cf70.tar.gz
taskman-lite-96b0f232f1fcb4b48a72dbe96f01270a09d4cf70.tar.xz
taskman-lite-96b0f232f1fcb4b48a72dbe96f01270a09d4cf70.zip
[daemon] Add log4j2 configuration for proper logging levels
-rw-r--r--daemon/pom.xml8
-rw-r--r--daemon/src/main/java/org/openslx/taskmanager/App.java5
-rw-r--r--daemon/src/main/properties/log4j2.properties21
3 files changed, 33 insertions, 1 deletions
diff --git a/daemon/pom.xml b/daemon/pom.xml
index 0412f3e..6253441 100644
--- a/daemon/pom.xml
+++ b/daemon/pom.xml
@@ -49,6 +49,14 @@
</configuration>
</plugin>
</plugins>
+ <resources>
+ <resource>
+ <directory>src/main/properties</directory>
+ <includes>
+ <include>*.properties</include>
+ </includes>
+ </resource>
+ </resources>
</build>
<dependencies>
diff --git a/daemon/src/main/java/org/openslx/taskmanager/App.java b/daemon/src/main/java/org/openslx/taskmanager/App.java
index cf63448..4251478 100644
--- a/daemon/src/main/java/org/openslx/taskmanager/App.java
+++ b/daemon/src/main/java/org/openslx/taskmanager/App.java
@@ -25,7 +25,10 @@ public class App
public static void main( String[] args ) throws InterruptedException, IOException
{
- Configurator.initialize( new DefaultConfiguration() );
+ // setup basic logging appender to log output on console if no external appender (log4j.properties) is configured
+ if (org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()).getAppenders().isEmpty()) {
+ Configurator.initialize(new DefaultConfiguration());
+ }
if (Global.PORT_UDP == -1 && Global.PORT_TCP == -1) {
log.fatal( "Neither UDP nor TCP configured" );
diff --git a/daemon/src/main/properties/log4j2.properties b/daemon/src/main/properties/log4j2.properties
new file mode 100644
index 0000000..563fe8d
--- /dev/null
+++ b/daemon/src/main/properties/log4j2.properties
@@ -0,0 +1,21 @@
+status=error
+name=log4j2PropertiesConfig
+
+#
+# root level logging configuration
+#
+rootLogger.level=all
+rootLogger.appenderRefs=stdout
+rootLogger.appenderRef.stdout.ref=logToConsole
+
+#
+# configuration for console output
+#
+appenders=console
+
+appender.console.type=Console
+appender.console.name=logToConsole
+appender.console.layout.type=PatternLayout
+appender.console.layout.pattern=[%t] %-5p %F - %m%n
+appender.console.filter.threshold.type=ThresholdFilter
+appender.console.filter.threshold.level=info