|
|
|
@ -303,7 +303,7 @@ public class DailyRollingFileAppender extends FileAppender {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
Rollover the current file to a new file. |
|
|
|
|
* Rollover the current file to a new file. |
|
|
|
|
*/ |
|
|
|
|
void rollOver() throws IOException { |
|
|
|
|
|
|
|
|
@ -320,10 +320,6 @@ public class DailyRollingFileAppender extends FileAppender {
|
|
|
|
|
if (scheduledFilename.equals(datedFilename)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
synchronized (this) { |
|
|
|
|
if (scheduledFilename.equals(datedFilename)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// close current file, and compress it to datedFilename
|
|
|
|
|
this.closeFile(); |
|
|
|
@ -351,11 +347,9 @@ public class DailyRollingFileAppender extends FileAppender {
|
|
|
|
|
LogLog.error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean isDeleteSuccess = true; |
|
|
|
|
if (result) { |
|
|
|
|
if (!file.delete()) { |
|
|
|
|
LogLog.debug("file delete failed, empty it."); |
|
|
|
|
emptyFile(file); |
|
|
|
|
} |
|
|
|
|
isDeleteSuccess = file.delete(); |
|
|
|
|
LogLog.debug(fileName + " -> " + scheduledFilename); |
|
|
|
|
} else { |
|
|
|
|
LogLog.error("Failed to rename [" + fileName + "] to [" + scheduledFilename + "]."); |
|
|
|
@ -368,6 +362,16 @@ public class DailyRollingFileAppender extends FileAppender {
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
errorHandler.error("setFile(" + fileName + ", true) call failed."); |
|
|
|
|
} |
|
|
|
|
if(!isDeleteSuccess){ |
|
|
|
|
synchronized (this) { |
|
|
|
|
if (scheduledFilename.equals(datedFilename)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
LogLog.debug("file delete failed, empty it."); |
|
|
|
|
emptyFile(file); |
|
|
|
|
scheduledFilename = datedFilename; |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
scheduledFilename = datedFilename; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|