From 1b0c4d3aa258cb0ef63ab3a6d82ed7b6171969e5 Mon Sep 17 00:00:00 2001 From: Gavin Chou Date: Wed, 20 Mar 2024 14:11:58 +0800 Subject: [PATCH] [chor](log) Change log4j rollover strategy to 'max' (#32116) The log file names are in the format fe.log.${date}-${index}, e.g. ``` fe.log.20240311-1 fe.log.20240311-2 fe.log.20240311-3 ... ``` In the previous, fe.log/fe.audit.log will be renamed to fe.log.xxx-1/fe.audit.log.xxx-1 with the minimum index `1` when they reach rotation size. e.g. ``` fe.log.20240311-1 -> fe.log.20240311-2 fe.log.20240311-2 -> fe.log.20240311-3 fe.log.20240311-3 -> fe.log.20240311-4 fe.log -> fe.log.20240311-1 ``` there are some drawbacks 1. log4j needs to rename all existing rotated log to spare the index `1` 2. it's hard to deal with the duplicated names, because every time the log rotates, it starts from index `1` After this change, the log will rename to a file name with larger index instead of `1`. e.g. when rotate ``` fe.log.20240311-1 fe.log.20240311-2 fe.log.20240311-3 fe.log -> fe.log.20240311-4 ``` --- .../src/main/java/org/apache/doris/common/Log4jConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java b/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java index 3c72048e00..47d96765a9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/Log4jConfig.java @@ -56,7 +56,7 @@ public class Log4jConfig extends XmlConfiguration { + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" @@ -71,7 +71,7 @@ public class Log4jConfig extends XmlConfiguration { + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" @@ -86,7 +86,7 @@ public class Log4jConfig extends XmlConfiguration { + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n"