Jiang Biao Thank you for this report. It turns out that setting the triggering policy to SizeBasedTriggeringPolicy after setting the rollingPolicy to class ch.qos.logback.core.rolling.TimeBasedRollingPolicy is the root cause of the NPE. I have modified the code to generate a warning with a link to an explanation. It is easy for forget that some rolling policies such as c.q.l.core.rolling.TimeBasedRollingPolicy and c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy act as both a rolling policy and a trigerring policy. When the triggering policy is to SizeBasedTriggeringPolicy, then ch.qos.logback.core.rolling.TimeBasedRollingPolicy never calls {{ ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy#isTriggeringEvent}} method which leaves the elapsed file name null. Anyway, removing
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
will solve the issue. If you wish to have size based trigerring in addition to time based trigerring/filenaming see SizeAndTimeBasedRollingPolicy in the manual. |