Bug 17531 - PropertyConfigurator.configureAndWatch() don't reset the configuration
PropertyConfigurator.configureAndWatch() don't reset the configuration
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Configurator
1.2
Other other
: P3 minor
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2003-02-28 16:08 UTC by Eric Chastan
Modified: 2007-08-22 14:20 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Chastan 2003-02-28 16:08:54 UTC
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);
    }
Comment 1 Legolas Greenleaf 2003-11-03 11:34:43 UTC
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.
Comment 2 Mark Womack 2005-07-01 23:01:42 UTC
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.
Comment 3 Elias Ross 2007-01-25 23:40:39 UTC
Fix added to 1.3, SVN trunk.

DTD modified to include attribute "reset" for <configuration>, default value is
"false"; "true" resets the repository.
Comment 4 Elias Ross 2007-01-26 14:23:21 UTC
For properties files, use the analogous "log4j.reset", default is false.
Comment 5 Curt Arnold 2007-01-30 10:29:47 UTC
Changes committed by Elias Ross in rev 500169 and rev 500384
Comment 6 Curt Arnold 2007-08-22 14:20:45 UTC
Committed against log4j 1.2 branch in rev 568750 and against extras companion in 568753.