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 
Besides the XML configuration some loggers and appendes are created 
dynamically in Java.

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

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

Appender appender = RollingFileAppender.newBuilder()...

LoggerConfig loggerConfig = LoggerConfig.createLogger(...)
loggerConfig.addAppender(appender, null, null);
config.addLogger(loggerName, loggerConfig);

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


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

View raw message