When the log4j properties file is changed only added logger are taken into account, removed logger are still enabled. I mean that if a logger is drop down from debug to warn it still prints debugging information after the log4j properties file has been saved. This is because in class PropertyWatchdog in doOnChange() method the configuration is not reset before reading the changed one -> Here is a correction that works fine for me: public void doOnChange() { LoggerRepository hierarchy = LogManager.getLoggerRepository(); hierarchy.resetConfiguration(); new PropertyConfigurator().doConfigure(filename,hierarchy); }
Thanx! Was just about to submit the exact same change. Altough there is an abbreviation availabel: public void doOnChange() { LogManager.resetConfiguration(); new PropertyConfigurator().doConfigure(filename, LogManager.getLoggerRepository()); } The same improvement also applies to the DOMConfigurator.
The "additive" nature of configuration application, as you describe it, is actually considered a feature. For 1.3 we are looking to add a "reset" option in the configuration file. Leaving this open until this feature is added to v1.3 code.
Fix added to 1.3, SVN trunk. DTD modified to include attribute "reset" for <configuration>, default value is "false"; "true" resets the repository.
For properties files, use the analogous "log4j.reset", default is false.
Changes committed by Elias Ross in rev 500169 and rev 500384
Committed against log4j 1.2 branch in rev 568750 and against extras companion in 568753.