You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Jianfei Jiang (JIRA)" <ji...@apache.org> on 2018/12/21 05:39:00 UTC

[jira] [Created] (LOG4J2-2524) Logs roll error when decrease the max count of log files

Jianfei Jiang created LOG4J2-2524:
-------------------------------------

             Summary: Logs roll error when decrease the max count of log files
                 Key: LOG4J2-2524
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2524
             Project: Log4j 2
          Issue Type: Bug
          Components: Configurators
    Affects Versions: 2.11.1
            Reporter: Jianfei Jiang


When using log4j2 version 2.11.1, and the original configurations like below:

{{appender.rolling.layout.type=PatternLayout}}
{{appender.rolling.fileName=/tmp/test.log}}
{{appender.rolling.name=rolling}}
{{appender.rolling.type=RollingFile}}
{{appender.rolling.layout.pattern=%d\{yyyy-MM-dd HH:mm:ss,SSS} %p %c: %m%n}}
{{appender.rolling.policies.type=Policies}}
{{appender.rolling.filePattern=/tmp/test-%i.log}}
{{appender.rolling.strategy.max=8}}
{{appender.rolling.strategy.type=DefaultRolloverStrategy}}
{{appender.rolling.policies.size.size=1M}}
{{appender.rolling.policies.size.type=SizeBasedTriggeringPolicy}}
{{rootLogger.appenderRef.rolling.ref=rolling}}
{{rootLogger.level=INFO}}

Eight backup logs created successfully:

{{jiangjianfei@zdh196:/tmp$ ll}}
{{total 9008}}
{{drwxr-xr-x 2 jiangjianfei users 4096 Dec 21 13:29 ./}}
{{drwxr-xr-x 40 jiangjianfei users 4096 Dec 21 10:04 ../}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-1.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-2.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-3.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-4.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-5.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-6.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-7.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-8.log}}
{{-rw-r--r-- 1 jiangjianfei users 793548 Dec 21 13:29 test.log}}

When I change the value of appender.rolling.strategy.max from 8 to 5, it occurs some errors and looks strange. The backup logs which indexed 1 to 3 is deleted and only test-5.log can be rewritten, which means now there is only one backup in use actually and the indices are in chaos.

{{jiangjianfei@zdh196:/tmp$ ll}}
{{total 4296}}
{{drwxr-xr-x 2 jiangjianfei users 4096 Dec 21 13:33 ./}}
{{drwxr-xr-x 40 jiangjianfei users 4096 Dec 21 10:04 ../}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-4.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 {color:#FF0000}13:33{color} test-5.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-6.log}}
{{-rw-r--r-- 1 jiangjianfei users 1048684 Dec 21 13:29 test-7.log}}
{{-rw-r--r-- 1 jiangjianfei users 177684 Dec 21 13:33 test.log}}

I wonder if it is actually a bug or I can avoid this problem using some configuration.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)