自动删除0字节的日志文件

This commit is contained in:
Redkale
2018-01-05 08:42:15 +08:00
parent 8ff829f1b1
commit e20619e0c9

View File

@@ -154,6 +154,8 @@ public class LogFileHandler extends Handler {
if (greater.exists()) Files.move(greater.toPath(), new File(logfile.getPath() + "." + (i + 1)).toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
}
Files.move(logfile.toPath(), new File(logfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
} else {
if (logfile.exists() && logfile.length() < 1) logfile.delete();
}
logstream = null;
}
@@ -166,6 +168,8 @@ public class LogFileHandler extends Handler {
if (greater.exists()) Files.move(greater.toPath(), new File(logunusualfile.getPath() + "." + (i + 1)).toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
}
Files.move(logunusualfile.toPath(), new File(logunusualfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
} else {
if (logunusualfile.exists() && logunusualfile.length() < 1) logunusualfile.delete();
}
logunusualstream = null;
}