Added level log4j2 configuration.
This commit is contained in:
parent
65354e89cc
commit
407f22692b
1 changed files with 19 additions and 1 deletions
|
@ -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<BuiltConfiguration> 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);
|
||||
|
|
Loading…
Reference in a new issue