Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-73

TimeBasedRollingPolicy can not be used with any other triggering policies

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • None
    • None
    • None
    • None

    Description

      If someone would like to have a time based rolling policy with a size based triggering policy, than the user will get a NullPointerException,:
      at ch.qos.logback.core.rolling.helper.Compress.GZCompress(Compress.java:130)
      at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:142)
      at ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:91)
      at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:116)
      at ch.qos.logback.core.WriterAppender.append(WriterAppender.java:124)
      at ch.qos.logback.core.AppenderBase.doAppend(AppenderBase.java:81)
      at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:51)
      at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:282)
      at ch.qos.logback.classic.Logger.callAppenders(Logger.java:266)
      at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:487)
      at ch.qos.logback.classic.Logger.filterAndLog(Logger.java:479)

      The cause of this issue is the isTriggeringEvent method in the TimeBasedRollingPolicy which has a side effect, namely it prepares the file name of the file which is about to rotate. If someone uses a triggering policy other than the same TimeBasedRollingPolicy, than the isTriggeringEvent method will not be called, hence the elapsedPeriodFileName will be null, hence a null pointer exception will be thrown in the start of the compression or while renaming.

      Please modify the isTriggeringEvent to not have this side effect + the rollover logic to capture the time information from the current event.
      Thanks,
      Zoltan

      Attachments

        Activity

          People

            ceki Ceki Gülcü
            zoliszel Szel Zoltan
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: