diff --git a/src/qz/App.java b/src/qz/App.java index 0ca651686..739123c89 100644 --- a/src/qz/App.java +++ b/src/qz/App.java @@ -102,7 +102,10 @@ private static void setupFileLogging() { .setFilter(ThresholdFilter.createFilter(Level.DEBUG, Filter.Result.ACCEPT, Filter.Result.DENY)) .withFileName(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".log") .withFilePattern(FileUtilities.USER_DIR + File.separator + Constants.LOG_FILE + ".%i.log") - .withStrategy(DefaultRolloverStrategy.newBuilder().withMax(String.valueOf(logRotate)).build()) + .withStrategy(DefaultRolloverStrategy.newBuilder() + .withMax(String.valueOf(logRotate)) + .withFileIndex("min") + .build()) .withPolicy(SizeBasedTriggeringPolicy.createPolicy(String.valueOf(logSize))) .withImmediateFlush(true) .build(); diff --git a/src/qz/installer/Installer.java b/src/qz/installer/Installer.java index 2c644af41..9893de33d 100644 --- a/src/qz/installer/Installer.java +++ b/src/qz/installer/Installer.java @@ -171,17 +171,24 @@ public Installer removeLibs() { } public Installer removeLegacyLogs(int rolloverCount) { - // Cleanup old < 2.2.3 log file format + // Convert old < 2.2.3 log file format Path logLocation = USER_DIR; + int nextFile = 0; for(int i = 1; i <= rolloverCount; i++) { // Old: debug.log.1 - File newFile = logLocation.resolve("debug." + i + ".log").toFile(); - // New: debug.1.log File oldFile = logLocation.resolve("debug.log." + i).toFile(); - // Only delete old if an adjacent new copy exists - if(oldFile.exists() && newFile.exists()) { - log.info("Cleaning up old log file {}", oldFile); - oldFile.delete(); + if(oldFile.exists()) { + // Rename to new format + inner: + while(true) { + // New: debug.1.log + File newFile = logLocation.resolve("debug." + ++nextFile + ".log").toFile(); + if (!newFile.exists()) { + oldFile.renameTo(newFile); + log.info("Migrated log file {} to new location {}", oldFile, newFile); + break inner; + } + } } }