Details
-
Improvement
-
Resolution: Unresolved
-
Trivial
-
None
-
1.0.13
-
None
-
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
Description
I ran into exactly this http://tonaconsulting.com/error-in-ch-qos-logback-core-joran-spi-interpreter2325-runtimeexception-in-action-for-tag-rollingpolicy-java-lang-indexoutofboundsexception-no-group-1/ (apparently someone else too) and believe that it could be detected when reading the configuration. I would prefer getting an invalid configuration exception at startup compared to the current runtime exception that only occurs rarely.
Example wrong config:
<fileNamePattern>var/log/mylog.log.%d
Correct config needs counter variable:
<fileNamePattern>var/log/mylog.log.%d{yyyy-MM}
(%i).zip</fileNamePattern>
The exception I received was
java.lang.IndexOutOfBoundsException: No group 1
Full config example:
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>var/log/myfile.log</file>
<encoder>
<pattern>%d
[%t] %-5p %m%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>var/log/myfile.%d
(%i).log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>3</maxHistory>
</rollingPolicy>
</appender>