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

Add CronTriggeringPolicy programmatically leads to NPE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.8
    • Component/s: Appenders
    • Labels:
      None

      Description

      When i try to add a RollingFileAppender with a CronTriggeringPolicy programmatically then I get a NPE because the ScheduledExecutorService in ConfigurationScheduler is null. IMO the ScheduledExecutorService should always be created even when there are no items which needs to be scheduled.

      Caused by: java.lang.NullPointerException
      at org.apache.logging.log4j.core.config.ConfigurationScheduler.schedule(ConfigurationScheduler.java:107) ~[log4j-core-2.7.jar:2.7]
      at org.apache.logging.log4j.core.config.ConfigurationScheduler.scheduleWithCron(ConfigurationScheduler.java:120) ~[log4j-core-2.7.jar:2.7]
      at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.initialize(CronTriggeringPolicy.java:72) ~[log4j-core-2.7.jar:2.7]
      at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.initialize(RollingFileManager.java:104) ~[log4j-core-2.7.jar:2.7]
      at org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.createAppender(RollingRandomAccessFileAppender.java:218) ~[log4j-core-2.7.jar:2.7]

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pni Peter Nimmervoll
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: