From 96b0f232f1fcb4b48a72dbe96f01270a09d4cf70 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Thu, 16 Dec 2021 12:58:44 +0100 Subject: [daemon] Add log4j2 configuration for proper logging levels --- daemon/pom.xml | 8 ++++++++ .../src/main/java/org/openslx/taskmanager/App.java | 5 ++++- daemon/src/main/properties/log4j2.properties | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 daemon/src/main/properties/log4j2.properties 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 @@ + + + src/main/properties + + *.properties + + + 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 -- cgit v1.2.3-55-g7522