[logback-user] FileNamePattern

Neil Lott neilmatthewlott at yahoo.com
Wed Feb 4 20:02:03 CET 2009


Hi,

I'm using a FileNamePattern with a FixedWindowPolicy:


Here's my appender:

<appender name="FILE"  
class="ch.qos.logback.core.rolling.RollingFileAppender">
         <file>/usr/local/mystro/logs/MSAServer.log</file>
         <append>true</append>

         <rollingPolicy  
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
             <FileNamePattern>/usr/local/neil/logs/MSAServer.%i. 
%d{yyyyMMdd-HHmmss}.gz</FileNamePattern>
             <MinIndex>1</MinIndex>
             <MaxIndex>3</MaxIndex>
         </rollingPolicy>

         <triggeringPolicy  
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
             <MaxFileSize>1KB</MaxFileSize>
         </triggeringPolicy>

         <layout class="ch.qos.logback.classic.PatternLayout">
             <Pattern>%d{ISO8601} %-5level [%thread] \(%logger{0}.%M:%L 
\\) - %msg%n</Pattern>
         </layout>
     </appender>

Here's the exception when the file rolls -- I had to alter the  
rollover method of FixedWindowPolicy in order to catch throwable to  
see what was going on:

java.lang.IllegalArgumentException: Cannot convert 3 of  
typejava.lang.Integer
	at  
ch 
.qos 
.logback 
.core 
.rolling.helper.DateTokenConverter.convert(DateTokenConverter.java:60)
	at  
ch 
.qos 
.logback 
.core.rolling.helper.FileNamePattern.convert(FileNamePattern.java:202)
	at  
ch 
.qos 
.logback 
.core.rolling.helper.FileNamePattern.convertInt(FileNamePattern.java: 
210)
	at  
ch 
.qos 
.logback 
.core 
.rolling 
.FixedWindowRollingPolicy.rollover(FixedWindowRollingPolicy.java:103)
	at  
ch 
.qos 
.logback 
.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:105)
	at  
ch 
.qos 
.logback 
.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java: 
128)
	at ch.qos.logback.core.WriterAppender.append(WriterAppender.java:119)
	at ch.qos.logback.core.AppenderBase.doAppend(AppenderBase.java:79)
	at  
ch 
.qos 
.logback 
.core 
.spi 
.AppenderAttachableImpl 
.appendLoopOnAppenders(AppenderAttachableImpl.java:60)
	at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
	at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
	at  
ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java: 
439)
	at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java: 
393)
	at ch.qos.logback.classic.Logger.info(Logger.java:597)
	at  
ch 
.qos 
.logback.classic.net.SimpleSocketServer.run(SimpleSocketServer.java:79)


Is this an intentional restriction to make the file name pattern have  
%i first and then %d?

Thanks,

Neil



More information about the Logback-user mailing list