diff options
author | Manuel Bentele | 2021-12-16 12:58:44 +0100 |
---|---|---|
committer | Manuel Bentele | 2021-12-16 12:58:44 +0100 |
commit | 96b0f232f1fcb4b48a72dbe96f01270a09d4cf70 (patch) | |
tree | b22ee34dd249424e4c77cebf8c40d30bf5788d44 | |
parent | [api] Update version of gson dependency (diff) | |
download | taskman-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.xml | 8 | ||||
-rw-r--r-- | daemon/src/main/java/org/openslx/taskmanager/App.java | 5 | ||||
-rw-r--r-- | daemon/src/main/properties/log4j2.properties | 21 |
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 |