DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13021>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13021 DailyRollingFileAppender - change renameTo Summary: DailyRollingFileAppender - change renameTo Product: Log4j Version: 1.2 Platform: PC OS/Version: Other Status: NEW Severity: Minor Priority: Other Component: Appender AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] reason: there may be another application that reads the log (a viewer), with RanomAccessFile (set on "R"). When you try to renameTo(), program fails to rename, and bye-bye the backup file; The same problem we encountered with RollingFileAppender I Propose: replace renameTo()... with copy(); the backup file is created all the times. present code: boolean result = file.renameTo(target); if(result) { LogLog.debug(fileName +" -> "+ scheduledFilename); } else { LogLog.error("Failed to rename ["+fileName+"] to ["+scheduledFilename+"]."); } proposed code: // copy file content to target instead of renaming it java.io.BufferedReader in = null; java.io.BufferedWriter out = null; try { if (getEncoding() == null) { in = new java.io.BufferedReader(new java.io.FileReader(file)); out = new java.io.BufferedWriter(new java.io.FileWriter(target)); } else { in = new java.io.BufferedReader(new java.io.InputStreamReader( new java.io.FileInputStream(file), getEncoding())); out = new java.io.BufferedWriter(new java.io.OutputStreamWriter( new java.io.FileOutputStream(target), getEncoding())); } int length; String line; while ((line = in.readLine()) != null) { if (line.length() != 0) { out.write(line); } out.newLine(); } LogLog.debug(fileName +" -> "+ scheduledFilename); }catch(java.io.IOException exc){ LogLog.error("Failed to copy [" + fileName + "] to [" + scheduledFilename + "]."); // exc.printStackTrace(); } finally { if (out != null) { out.close(); } if (in != null) { in.close(); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>