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 Michael Reidy <Mi...@S1.com> on 2003/07/29 13:29:45 UTC

RollingFileAppender rollOver() Method Silently Fails


Hello All,

not sure if this is the correct forum for this, but anyways.... I was
debugging a problem I had and noticed the following:  2 RollingFileAppenders
open on the same file, caused the removal of all but the current trace file,
I could also explain why this happened but this much more important....I
looked at the code for RollingFileAppender and saw code like this:

Example 1: 

	if (file.exists())
		file.delete();

Example 2:

	LogLog.debug("Renaming file " + file + " to " + target);
	file.renameTo(target);
			

The problem I have with this is that the file.delete() and the
file.renameTo() can fail, but you are not checking if it has.  Both of these
methods return booleans to indicate success or failure.  The least that
could be done is that you log the failure to your own log, otherwise you
could throw and exception or indeed flag it in a return code yourself...


Mike Reidy.

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