logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Heinen <mhn4...@googlemail.com>
Subject Programmatically added loggers lost due to automatic reconfiguration
Date Fri, 29 Sep 2017 12:30:20 GMT
I use Log4j 2.9.1 with the XML configuration. A monitorInterval is 
specified in the XML config in order to reconfigure log4j, e.g. for 
debugging.
Besides the XML configuration some loggers and appendes are created 
dynamically in Java.

Problem:
The dynamically added loggers and appenders are lost after the XML 
configuration has been reloaded.

<javaCode>
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();

Appender appender = RollingFileAppender.newBuilder()...
config.addAppender(appender);

LoggerConfig loggerConfig = LoggerConfig.createLogger(...)
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);
ctx.updateLoggers();
<javaCode>

Could the dynamically added loggers/appenders be isolated from the 
automatic reconfiguration?
Is there another way to add them programamtically?

Thanks,
Michael


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message