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

RollingFile Appender rolls over differently from Log4j1.x implementation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Bug
    • 2.11.0
    • None
    • Appenders
    • None

    Description

      We upgraded our web application to have Log4j 2.11 (from Log4j 1.2.15) with some backward compatibility using log4j 1.x API, so that other Apache distros can work without breaking things. We have verified the binding of new log4j2 with SLF4J and confirmed that the log4j2.xml is indeed the only reference for log configuration.

      One of the things we have observed is the discrepancy in rollover behaviour for RollingFile.

      In log4j 1.x the rollover occurred in this way:

       

      1) my file pattern is C:/mylogdir/my-log-file.log.%i.

      2) When size-based policy is met, the rollover would be such that:

           i) the active log file segment will be my-log-file.log

           ii) the next one (immediate recent) will be my-log-file.log.1

           iii) the next one (immediate recent after ii above) will be my-log-file.log.2

       

      Since log4j 2.11 upgrade, what we can see is:

       

          i) The active log file segment is my-log-file.log

          ii) The next one (immediate recent) is my-log-file.log.N - where X is the max number of segment created so far.

          iii) The next one (after ii segment above) is my-log-file.log.N-1

      So for Log4j2.11 the segments are rolled over in incorrect order, and creating confusion within our support staff. Our config file is attached.

      What we can see from docs is that the fileIndex is defaulted to Max i.e. it's following the non-fixed window strategy for indexing. Is there any reason why 2.11 has this defaulted? This creates confusion since 1.2.x default wasn't this one.

      Regards,

      Attachments

        1. log4j2.xml
          2 kB
          M. Manna

        Activity

          People

            Unassigned Unassigned
            manmedia@gmail.com M. Manna
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: