Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2524

Logs roll error when decrease the max count of log files

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.11.1
    • Fix Version/s: None
    • Component/s: Configurators
    • Labels:
      None

      Description

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

      appender.rolling.layout.type=PatternLayout
      appender.rolling.fileName=/home/jiangjianfei/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=/home/jiangjianfei/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-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-1.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-2.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-3.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-4.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-5.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-6.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-7.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-8.log
      rw-rr- 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-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-4.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:33 test-5.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-6.log
      rw-rr- 1 jiangjianfei users 1048684 Dec 21 13:29 test-7.log
      rw-rr- 1 jiangjianfei users 177684 Dec 21 13:33 test.log

       

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jiangjianfei Jianfei Jiang

              Dates

              • Created:
                Updated:

                Issue deployment