logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McDonnell, Colm (MLIM)" <colm_mcdonn...@ml.com>
Subject RollingFileAppender issue
Date Thu, 02 Dec 2004 17:27:34 GMT
I am using log4j to log a web application running under WebLogic 8.1 SP1
on Windows 2000/XP. I am using a RollingFileAppender with a standard


The log file size reaches its "MaxFileSize" and instead of rolling, the
log file is cleared down and subsequent events are written into the
original file. 


Log4J's own log output indicates that nothing is wrong e.g.

log4j: rolling over count=20566
log4j: maxBackupIndex=5
log4j: Renaming file \bob.log to \bob.log.1
log4j: setFile called: /bob.log, false
log4j: setFile ended

The problem arises in org.apache.log4j.RollingFileAppender.rollOver() at
line 139 ( file.renameTo(target); ), using FileMon in parallel with
debugging the Log4J code I discovered that the renameTo instruction
fails on a shared access violation, then when I looked at this file
using ProcessExplorer I discovered that WebLogic had multiple file
handles open to the same file. Further investigation showed that these
files are left open when I stop and restart the application, in other
words the open file handle which log4j has on the log file is not closed
when the application is stopped. Killing the WebLogic process causes all
file handles to be closed and we are back to the situation where the
RollingFileAppender works because the only open file handle is the one
it is currently using. However, the next time the application is
restarted the issue reappears and so on ....

The same RollingFileAppender configuration works with Tomcat (on Windows
2000/XP and Solaris) and with WebLogic 6.1/8.1 (on UNIX). So, it seems
like it might be related to some assumptions log4j makes about how the
application (or its container) will close file handles which conflict
with what WebLogic actually does on the Windows platform. And yet, if
this was true surely I would have found details of this issue in the
mailing lists and on Google etc. 

Anyway, I am aware that this may not be the best place to post this
issue however I am hoping that someone on this list may have encountered
this issue previously. In particular I am interested to know how log4j
expects an open file handle to be closed, the only code I have found in
the code base is the closeFile() method on FileAppender and its sub
classes however this is not intended to be called on application
shutdown so I am assuming that log4j assumes that the application will
be responsible for closing any file handles. 
If you are not an intended recipient of this e-mail, please notify the sender, delete it and
do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important
additional terms relating to this e-mail.     http://www.ml.com/email_terms/ 

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message