diff --git a/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java b/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java index d07b413..cc9fb29 100644 --- a/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java +++ b/src/fr/devinsy/statoolinfos/StatoolInfosLauncher.java @@ -71,13 +71,31 @@ public final class StatoolInfosLauncher } else { + // + Level logEnvLevel = Level.getLevel(System.getenv().get("LOG4J_LEVEL")); + Level logPropertyLevel = Level.getLevel(System.getProperty("log4j2.level")); + + Level level; + if (logPropertyLevel != null) + { + level = logPropertyLevel; + } + else if (logEnvLevel != null) + { + level = logEnvLevel; + } + else + { + level = Level.INFO; + } + // Build a custom default log configuration. ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder(); builder.setStatusLevel(Level.ERROR); builder.setConfigurationName("CustomDefaultLogger"); AppenderComponentBuilder appenderBuilder = builder.newAppender("Console", "CONSOLE").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT); appenderBuilder.add(builder.newLayout("PatternLayout").addAttribute("pattern", "%m%n")); - RootLoggerComponentBuilder rootLogger = builder.newRootLogger(Level.INFO); + RootLoggerComponentBuilder rootLogger = builder.newRootLogger(level); rootLogger.add(builder.newAppenderRef("Console")); builder.add(appenderBuilder); builder.add(rootLogger);