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 2006/09/21 14:54:28 UTC

DO NOT REPLY [Bug 40570] New: - RollingFileAppender does not rollover when the file already exists

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=40570>.
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=40570

           Summary: RollingFileAppender does not rollover when the file
                    already exists
           Product: Log4j
           Version: 1.3alpha
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: peter_clewlow@nl.ibm.com


When it is time to rollover and a backup log file must be created but that 
file name already exists the rollover fails. This used to work in log4j 
version 1.2 in class DailyRollingFileAppender method rollOver() where the code 
first deletes the target file if it already exists. In log4j version 1.3alpha 
similar code could be added in class FileRenameAction method execute() to fix 
this issue.

-- 
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 40570] - RollingFileAppender does not rollover when the file already exists

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=40570>.
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=40570





------- Additional Comments From kay.abendroth@raxion.net  2006-11-12 12:13 -------
I would suggest to change:

  public static boolean execute(
    final File source, final File destination, boolean renameEmptyFiles) {
    if (renameEmptyFiles || (source.length() > 0)) {
      return source.renameTo(destination);
    }

    return source.delete();
  }

into:

  public static boolean execute(
    final File source, final File destination, boolean renameEmptyFiles) {
	  if (renameEmptyFiles || (source.length() > 0)) {
		  if(destination.delete()) {
			  return source.renameTo(destination); 
		  }
		  
		  return false; // Destination file deletion failed.
	  }
	  
	  return source.delete();
  }


-- 
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 40570] - RollingFileAppender does not rollover when the file already exists

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=40570>.
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=40570


kay.abendroth@raxion.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kay.abendroth@raxion.net
OtherBugsDependingO|                            |40173
              nThis|                            |
           Severity|normal                      |blocker
             Status|NEW                         |ASSIGNED




------- Additional Comments From kay.abendroth@raxion.net  2006-11-12 11:45 -------
To quote the Java-Doc for io.File.renameTo():
"Many aspects of the behavior of this method are inherently platform-dependent:
The rename operation might not be able to move a file from one filesystem to
another, it might not be atomic, and it might not succeed if a file with the
destination abstract pathname already exists. The return value should always be
checked to make sure that the rename operation was successful."

Should be blocker for next alpha release 1.3alpha9

-- 
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