Friday, 20 August 2010

Log4j reloading a properties file

Heads up for a funky log4j story:

PropertyConfigurator has a lovely method ' configureAndWatch()' which will reload the properties file if it changes.

However it doesn't completely reload it as the existing configuration is not cleared nor reset. Hence you can only change the level of existing logs and not comment out or add new package level logs.

To fix the above and completely reload the log4j file you must add log4j.reset=true to your properties file. This will cause the old properties data to be wiped before the file is loaded.

Sourced from the log4j mailing list

No comments:

Post a Comment