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

Automatic Reconfiguration fails in case of change in the triggeringpolicy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Duplicate
    • 2.12.0
    • 2.13.2
    • Core
    • None
    • Windows 10 + Tomcat 8.5 + Log4j2

    Description

      Hi all,

      I'm using log4j2 in a web app. I'm using RollingFileAppender and monitorInterval.

      The automatic reconfiguration fails with the following exception:

      java.lang.IllegalStateException: Pattern does not contain a date

      Steps:-

      • Change filePattern from "${web:rootDir}/server.%i.log" to "${web:rootDir}/server.log.%d{yyyy-MM-dd}"
      • Remove <SizeBasedTriggeringPolicy size="2MB"/> from <Policies> and add <TimeBasedTriggeringPolicy interval="1"/>
      • Save log4j2.xml

      What I suspect?

      The RollingFileManager sets the triggering policy first and then sets the patternprocessor.

      While setting the triggering policy, it uses the old pattern which does not contain the RolloverFrequency. So, it throws IllegalStateException with the message

      "Pattern does not contain a date".

      Possible solution?

      In the updateData() of RollingFileManager, set the new pattern processor first and then set the triggering policy.

      I have also attached my log4j2.xml and the stacktrace of the error for your reference.

      Please assist with the issue.

      Thanks

      Attachments

        1. log4j2.xml
          1 kB
          gaurav
        2. stacktrace.log
          3 kB
          gaurav

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gaurav9822 gaurav
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: