VJS
VJS

Reputation: 2953

Adding and Removing Loggers at runtime in log4j.xml

I am adding loggers at runtime in log4j.xml

<logger name="com.bas">    
       <priority value="DEBUG"/>
       <appender-ref ref="B2BAPP"/>
</logger>

my java code for loding runtime log4j.xml

LogManager.resetConfiguration();
DOMConfigurator.configureAndWatch(log4j.xml,100000L);

Getting loggers at runtime in java code through:

Enumeration enumLoggers = 
      Logger.getRootLogger().getLoggerRepository().getCurrentLoggers();

When I am adding logger to the log4j then I get the logger name in enumLoggers but if I remove any existing loggger (like removed logger "com.bas") then its not getting removed from enumLogger even after the specified time delay (ie 100000L in this case).

May I know why? Is there anything I am missing?

Upvotes: 2

Views: 1246

Answers (1)

MaDa
MaDa

Reputation: 10762

A quick look at the XMLWatchdog class (and its super class) reveals that it does not call LogManager.resetConfiguration(), so perhaps this is the reason? It's probably meant to work "incrementally".

Upvotes: 1

Related Questions