diff options
author | Manuel Bentele | 2021-06-01 14:13:11 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-06-01 14:13:11 +0200 |
commit | 033239af5af57551ac2424f0e46b594484dbb1ca (patch) | |
tree | 46d363f40407313ab95e26f458ad71be0d2988e9 | |
parent | Refactor container network to match common Docker network (diff) | |
download | masterserver-033239af5af57551ac2424f0e46b594484dbb1ca.tar.gz masterserver-033239af5af57551ac2424f0e46b594484dbb1ca.tar.xz masterserver-033239af5af57551ac2424f0e46b594484dbb1ca.zip |
Set log4j debug level for console (INFO)
-rw-r--r-- | pom.xml | 2 | ||||
-rw-r--r-- | src/main/java/org/openslx/imagemaster/App.java | 21 | ||||
-rw-r--r-- | src/main/properties/log4j.properties | 15 |
3 files changed, 22 insertions, 16 deletions
@@ -138,7 +138,7 @@ <resource> <directory>src/main/properties</directory> <includes> - <include>**/*.properties</include> + <include>*.properties</include> </includes> </resource> </resources> diff --git a/src/main/java/org/openslx/imagemaster/App.java b/src/main/java/org/openslx/imagemaster/App.java index 4bb7730..6b68770 100644 --- a/src/main/java/org/openslx/imagemaster/App.java +++ b/src/main/java/org/openslx/imagemaster/App.java @@ -6,11 +6,13 @@ import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.LogManager; import org.apache.log4j.Logger; import org.apache.thrift.transport.TTransportException; import org.openslx.imagemaster.localrpc.NetworkHandler; import org.openslx.imagemaster.thrift.server.BinaryListener; -import org.slf4j.LoggerFactory; +import org.openslx.sat.thrift.version.Version; /** * The main class that starts all the services. @@ -22,16 +24,17 @@ public class App private static List<Thread> servers = new ArrayList<>(); - static { - // This is a temporary workaround for this annoying log4j error msg. - // It's initializing the logger before anything else is done. - LoggerFactory.getLogger( "ROOT" ); - } - public static void main( String[] args ) throws TTransportException, NoSuchAlgorithmException, SocketException { - // Init logging - log.info( "Starting Application" ); + // setup basic logging appender to log output on console if no external appender (log4j.properties) is configured + if ( LogManager.getRootLogger().getAllAppenders() == null ) { + BasicConfigurator.configure(); + } + + log.info( "****************************************************************" ); + log.info( "******************* Starting Application ***********************" ); + log.info( "****************************************************************" ); + log.info( "RPC version " + Version.VERSION ); // Create binary listener Thread t; diff --git a/src/main/properties/log4j.properties b/src/main/properties/log4j.properties index 881887e..3baa9b6 100644 --- a/src/main/properties/log4j.properties +++ b/src/main/properties/log4j.properties @@ -1,11 +1,14 @@ -log4j.rootLogger=DEBUG, A1 +# root level logging configuration +log4j.rootLogger=ALL, console -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -log4j.appender.A1.layout=org.apache.log4j.PatternLayout - -log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %F - %m%n +# configuration for console output +log4j.appender.console=org.apache.log4j.ConsoleAppender +log4j.appender.console.layout=org.apache.log4j.PatternLayout +log4j.appender.console.layout.ConversionPattern=[%t] %-5p %F - %m%n +log4j.appender.console.encoding=UTF-8 +log4j.appender.console.Threshold=INFO +# overwrite logging level for specific packages and classes log4j.logger.org.apache.directory=ERROR log4j.logger.org.apache.mina=ERROR log4j.logger.org.apache.thrift.server.AbstractNonblockingServer=ERROR |