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

evaluateOnStartUp with CronTriggeringPolicy file renaming behavior at midnight on service restart

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Cannot Reproduce
    • 2.14.0
    • None
    • Appenders
    • None

    Description

      Hi.
      I tried CrontriggeringPolicy(added 2.14.0 version) for rolling daily log files at midnight. I have set evaluateOnStartup="true".
      My goal is, for example.
      if today is 2020/01/01, "catalina.log" is my active log file.
      and at midnight, "catalina.log" should be renamed to "catalina_20200101.log", and create new "catalina.log".

      At midnight, "catalina.log" got correctly renamed to "catalina_20200101.log" and new catalina.log" got created. 

      Then I stopped my service and restarted. I found that immediately another file "catalina_20200102.log" with same date got created. 

       

      It should not have happened as the midnight rollover already happened. On service restart it should not roll over the file again with same date time stamp.

       

      Please look into it.

       

      Here's my configure xml.

       

      <?xml version="1.0" encoding="UTF-8"?>
       <Configuration status="debug">
       <Properties>
       <Property name="baseDir">${sys:catalina.base}/logs</Property>
       </Properties>
       <Appenders>
       <RollingFile name="DailyRollingFile" fileName="${baseDir}/catalina.log" filePattern="${baseDir}/catalina_%d{yyyy-MM-dd}.log." append="true">
       <PatternLayout>
       <Pattern>%d{MMM dd, yyyy HH:mm:ss a} %c %M %p: %m%n</Pattern>
       </PatternLayout>
       <Policies>
       <CronTriggeringPolicy schedule="0 0 0 * * ?" evaluateOnStartup="true"/>
       </Policies>
       <DefaultRolloverStrategy>
       <Delete basePath="${baseDir}">
       <IfFileName glob="catalina_*.log" />
       <IfLastModified age="15d" />
       </Delete>
       </DefaultRolloverStrategy>
       </RollingFile>
       </Appenders>
       <Loggers>
       <Root level="info">
       <AppenderRef ref="DailyRollingFile"/>
       </Root>
       </Loggers>
       </Configuration>

      Attachments

        Activity

          People

            Unassigned Unassigned
            tray Tapan Ray
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: