Hi Michael,

How about
using 
org.apache.logging.log4j.core.config.Configuration.addListener(ConfigurationListener)
?

Gary



On Fri, Sep 29, 2017 at 6:30 AM, Michael Heinen <mhn4...@googlemail.com>
wrote:

> 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-unsubscr...@logging.apache.org
> For additional commands, e-mail: log4j-user-h...@logging.apache.org
>
>

Reply via email to