DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=42148>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=42148 Summary: PropertyConfigurator.configure() does not close properties file Product: Log4j Version: 1.2 Platform: All OS/Version: Windows XP Status: NEW Severity: blocker Priority: P1 Component: Configurator AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] We have a webapp that must be able to start logging during production. Our solution is to start a timer thread from its ContextListener that regularly re-initializes the configuration from a log4j.properties file: LogManager.resetConfiguration(); ClassLoader cl = this.getClass().getClassLoader(); URL log4jPropsUrl = cl.getResource("log4j.properties"); if (log4jPropsUrl != null) PropertyConfigurator.configure(log4jPropsUrl); else log.warn("log4j properties not found"); However, this locks the log4j.properties file, located in the webapp directory, so that a hot redeploy fails; Tomcat can't delete log4j.properties since it is locked. That is a show-stopper for us. I have checked the source code of PropertyConfigurator, and think I have found the bug. The method doConfigure calls props.load(configUrl.openStream()); but it does not call close() on the resulting InputStream. It must be closed, or the file will be locked, at least on Windows. A fix may look like: InputStream is = configUrl.openStream(); props.load(is); is.close(); We have encountered serveral other problems with files locked by log4j, but they are harder to track down. Searching the web also turns up several frustrations with files unnecessarily locked by log4j. It would therefore probably be a very good idea to search the log4j source code for similar constructs elsewhere and add close() wherever necessary. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
