From 1c2c89ece5b42f1e85f9b79904d8e47b8f84f4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9C=B0=E5=B9=B3=E7=BA=BF?= <22250530@qq.com> Date: Wed, 2 Sep 2015 11:29:26 +0800 Subject: [PATCH] --- src/com/wentch/redkale/boot/LogFileHandler.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/com/wentch/redkale/boot/LogFileHandler.java b/src/com/wentch/redkale/boot/LogFileHandler.java index e21921c1f..a98ac6911 100644 --- a/src/com/wentch/redkale/boot/LogFileHandler.java +++ b/src/com/wentch/redkale/boot/LogFileHandler.java @@ -113,15 +113,18 @@ public class LogFileHandler extends Handler { while (true) { try { LogRecord record = records.take(); - if ((limit > 0 && limit <= length.get()) || tomorrow <= record.getMillis()) { + final boolean bigger = (limit > 0 && limit <= length.get()); + if (bigger || tomorrow <= record.getMillis()) { updateTomorrow(); if (stream != null) { stream.close(); - for (int i = Math.min(count - 2, index.get() - 1); i > 0; i--) { - File greater = new File(logfile.getPath() + "." + i); - if (greater.exists()) Files.move(greater.toPath(), new File(logfile.getPath() + "." + (i + 1)).toPath(), REPLACE_EXISTING, ATOMIC_MOVE); + if (bigger) { + for (int i = Math.min(count - 2, index.get() - 1); i > 0; i--) { + File greater = new File(logfile.getPath() + "." + i); + 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); } - Files.move(logfile.toPath(), new File(logfile.getPath() + ".1").toPath(), REPLACE_EXISTING, ATOMIC_MOVE); stream = null; } }