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

RollingFileManager OnStartupTriggeringPolicy never rolls the file on startup

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.11.1
    • 2.11.2
    • Appenders
    • None

    Description

      I'm trying to get log4j2 (V2.11.1) to roll the existing log file at startup before it starts logging into a new file. My config is atached to the jira. I'm using a RollingFileManager with a OnStartupTriggeringPolicy with minSize=0, which, according to the documentation should be sufficient.

      However what i'm finding is that at startup, the OnStartupTriggeringPolicy class initialize method compares the timestamp of the log file to the JVM startup, and if the log file time is after the start-up time then it won't roll the file. If I step through the code then I see that at the point that check is made the file time is always after the JVM start time, because log4j2 appears to have already opened the file for writing at that point.

      More info here:

      https://stackoverflow.com/questions/53632091/log4j2-rollingfilemanager-onstartuptriggeringpolicy-never-rolls-the-file-on-star

       

      Attachments

        1. log4j2_debug.log
          13 kB
          Jon Hanson
        2. log4j2.json
          1 kB
          Jon Hanson

        Activity

          People

            Unassigned Unassigned
            jonhanson Jon Hanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: