Browse Source

REPORT-42043 fanruan.log无法分割-代码质量

bokai 4 years ago
parent
commit
40690479c1
  1. 19
      fine-log4j/src/main/java/com/fr/third/apache/log4j/DailyRollingFileAppender.java

19
fine-log4j/src/main/java/com/fr/third/apache/log4j/DailyRollingFileAppender.java

@ -174,7 +174,7 @@ public class DailyRollingFileAppender extends FileAppender {
The precise time when a rollover occurs depends on logging
activity.
*/
private volatile String scheduledFilename;
private String scheduledFilename;
/**
The next time we estimate a rollover should occur. */
@ -336,13 +336,9 @@ public class DailyRollingFileAppender extends FileAppender {
File file = new File(fileName);
boolean result = false;
FileInputStream fis = null;
FileOutputStream fos = null;
GZIPOutputStream gzos = null;
try {
fis = new FileInputStream(file);
fos = new FileOutputStream(target);
gzos = new GZIPOutputStream(fos);
try (FileInputStream fis =new FileInputStream(file) ;
FileOutputStream fos = new FileOutputStream(target);
GZIPOutputStream gzos = new GZIPOutputStream(fos);){
byte[] inbuf = new byte[8102];
int n;
@ -353,13 +349,6 @@ public class DailyRollingFileAppender extends FileAppender {
} catch (Exception e) {
LogLog.error("Compress " + fileName + " to " + scheduledFilename + " failed.");
LogLog.error(e.getMessage(), e);
} finally {
if (gzos != null) {
gzos.close();
}
if (fis != null) {
fis.close();
}
}
if (result) {

Loading…
Cancel
Save