This commit is contained in:
Redkale
2017-02-15 20:56:28 +08:00
parent 9eee3bfa58
commit fc6b5cb458

View File

@@ -156,17 +156,17 @@ public class LogFileHandler extends Handler {
} }
logstream = null; logstream = null;
} }
if (unusual != null && logunusualstream != null) { }
logunusualstream.close(); if (unusual != null && changeday && logunusualstream != null) {
if (limit > 0 && limit <= logunusuallength.get()) { logunusualstream.close();
for (int i = Math.min(count - 2, logunusualindex.get() - 1); i > 0; i--) { if (limit > 0 && limit <= logunusuallength.get()) {
File greater = new File(logunusualfile.getPath() + "." + i); for (int i = Math.min(count - 2, logunusualindex.get() - 1); i > 0; i--) {
if (greater.exists()) Files.move(greater.toPath(), new File(logunusualfile.getPath() + "." + (i + 1)).toPath(), REPLACE_EXISTING, ATOMIC_MOVE); File greater = new File(logunusualfile.getPath() + "." + i);
} 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);
} }
logunusualstream = null; Files.move(logunusualfile.toPath(), new File(logunusualfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
} }
logunusualstream = null;
} }
if (logstream == null) { if (logstream == null) {
logindex.incrementAndGet(); logindex.incrementAndGet();