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 bu...@apache.org on 2007/04/17 16:52:00 UTC
DO NOT REPLY [Bug 42148] New: - PropertyConfigurator.configure() does not close properties file
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: log4j-dev@logging.apache.org
ReportedBy: per.lindberg@implior.com
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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
DO NOT REPLY [Bug 42148] - PropertyConfigurator.configure() does not close properties file
Posted by bu...@apache.org.
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
carnold@apache.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |DUPLICATE
------- Additional Comments From carnold@apache.org 2007-04-17 08:44 -------
This looks exactly like bug 40944 which is fixed in the SVN. The fix was in the first release candidate for
log4j 1.2.15 (currently at http://people.apache.org/builds/logging/log4j/1.2.15/) which failed to be
released due to lack of sufficient votes. Please check if that takes care of your observed problem.
*** This bug has been marked as a duplicate of 40944 ***
--
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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
DO NOT REPLY [Bug 42148] - PropertyConfigurator.configure() does not close properties file
Posted by bu...@apache.org.
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
------- Additional Comments From per.lindberg@implior.com 2007-04-19 06:22 -------
Yes, I have just verified that the fix in log4j 1.2.15 RC1 solves the problem.
Excellent! Many thanks!
--
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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org