Skip to content

Commit

Permalink
Change rolled over log file suffix to .rolled-over.log
Browse files Browse the repository at this point in the history
  • Loading branch information
lovesh-ap committed Jan 15, 2025
1 parent 56e0011 commit a5de389
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static void rollover(String fileName) throws IOException {
if (Files.size(currentFile.toPath()) > maxFileSize) {
try (FileLock lock = FileChannel.open(currentFile.toPath(), StandardOpenOption.WRITE).lock()) {
if (lock.isValid() && currentFile.exists() && Files.size(currentFile.toPath()) > maxFileSize) {
File rolloverFile = new File(fileName + STRING_DOT + Instant.now().toEpochMilli());
File rolloverFile = new File(fileName + STRING_DOT + Instant.now().toEpochMilli() + STRING_DOT + "rolled-over.log");
FileUtils.moveFile(currentFile, rolloverFile);
}
lock.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static boolean isDailyRollover() {
}

public static void deleteRolloverLogFiles(String fileName, long max) {
Collection<File> rolloverLogFiles = FileUtils.listFiles(new File(OsVariablesInstance.getInstance().getOsVariables().getLogDirectory()), FileFilterUtils.and(FileFilterUtils.prefixFileFilter(fileName + "."), FileFilterUtils.suffixFileFilter(".log")), null);
Collection<File> rolloverLogFiles = FileUtils.listFiles(new File(OsVariablesInstance.getInstance().getOsVariables().getLogDirectory()), FileFilterUtils.and(FileFilterUtils.prefixFileFilter(fileName + "."), FileFilterUtils.suffixFileFilter(".rolled-over.log")), null);

if (rolloverLogFiles.size() > max) {
File[] sortedLogFiles = rolloverLogFiles.toArray(new File[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private static void rollover(String fileName) throws IOException {
if (Files.size(currentFile.toPath()) > maxFileSize) {
try (FileLock lock = FileChannel.open(currentFile.toPath(), StandardOpenOption.WRITE).lock()) {
if (lock.isValid() && currentFile.exists() && Files.size(currentFile.toPath()) > maxFileSize) {
File rolloverFile = new File(fileName + STRING_DOT + Instant.now().toEpochMilli());
File rolloverFile = new File(fileName + STRING_DOT + Instant.now().toEpochMilli() + STRING_DOT + "rolled-over.log");
FileUtils.moveFile(currentFile, rolloverFile);
}
lock.release();
Expand Down

0 comments on commit a5de389

Please sign in to comment.