You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Rob Butler <ro...@verizon.net> on 2004/01/21 23:19:31 UTC

Re: Bug fix & reload behavior modification / feature request

Included is a patch for log4j 1.2.8.  The patch is for two things.

1) log4j 1.2.8 PropertyConfigurator & DOMConfigurator both have a small bug in the  void doConfigure(URL url, LoggerRepository repository) methods.  They open a stream on the URL, but do not close it.  This means the file cannot be edited while the application is running because log4j has it locked.  This is easy to fix by closing the stream when log4j has finished reading it.

2) Added a new method to LogManager called refreshConfiguration().  This method will call a newly modified Hierarchy.resetConfiguration.  The old signature was resetConfiguration() and the new one is
resetConfiguration(boolean warnNoEmit).  If the parameter is true, log4j will emit a "Please initialize the log4j system properly." message if any thread attempts to log before the configuration is reloaded.  If false, the message will never be output.  The LogManager.refreshConfiguration() will then re-load the configuration file that was used when the app first started.

Log messages that occur between the reset and reload are lost.  If the new configuration file fails, log4j will output a message to stdout, and no logging will take place until the error in the file is corrected and LogManager.refreshConfiguration() is called again.  If the file is ok at that point, logging will resume using the the settings in the new configuration.

Let me know if this patch gets accepted, or other modifications to it are needed.

Later
Rob