[LOGBack-user] Unable to use RollingFileAppender

Sebastien Pennec sebastien at qos.ch
Fri Sep 15 14:30:48 CEST 2006


Hello all,

Just a quick correction on the last sent configuration file (first example).

There was a misspelled class name that should be corrected before the config can be 
used as-is.

Here is the config file that I've just tested and that works:

<configuration>
   <appender name="bitranlog" class="ch.qos.logback.core.rolling.RollingFileAppender">
     <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
       <param name="ActiveFileName" value="bitran.log" />
       <param name="FileNamePattern" value="bitran.%i.log" />
       <param name="MinIndex" value="1" />
       <param name="MaxIndex" value="3" />
     </rollingPolicy>

     <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
       <param name="MaxFileSize" value="5MB" />
     </triggeringPolicy>
     <layout class="ch.qos.logback.classic.PatternLayout">
       <param name="Pattern" value="%-4relative [%thread] %-5level %class - %msg%n" />
     </layout>
   </appender>
	
   <root>
     <level value="debug" />
     <appender-ref ref="FILE" />
   </root>
</configuration>

Sébastien

Ceki Gülcü a écrit :
> 
> Hello Samuel,
> 
> I'd try the following. (Apologies, I did not have time to test it, so
> it might contain minor mistakes.)
> 
>   <appender name="bitranlog" 
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>     <rollingPolicy 
> class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
>       <param name="ActiveFile" value="bitran.log" />
>       <param name="FileNamePattern" value="bitran.%i.log" />
>       <param name="MinIndex" value="1" />
>       <param name="MaxIndex" value="3" />
>     </rollingPolicy>
> 
>     <triggeringPolicy 
> class="ch.qos.logback.core.rolling.SizeBasedRollingPolicy">
>       <param name="MaxFileSize" value="5MB" />
>     </triggeringPolicy>
> 
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <param name="pattern" value="%-4relative [%thread] %-5level %class 
> - %msg%n" />
>     </layout>
>   </appender>
> 
> The TimeBasedRollingPolicy based example that you would usually want
> to use in real life (instead of the above) is less verbose, and just as 
> powerful.
> 
>   <appender name="FILE" 
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>     <rollingPolicy 
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>       <param name="FileNamePattern" value="foo_%d{yyyy-MM}.log".zip />
>       <param name="ActiveFileName" value="foo.log" />
>     </rollingPolicy>
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <param name="Pattern" value="%-4relative [%thread] %-5level %class 
> - %msg%n" />
>     </layout>
>   </appender>
> 
> You might also want to have a look at the javadocs.
> 
> http://logback.qos.ch/apidocs/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.html 
> 
> http://logback.qos.ch/apidocs/ch/qos/logback/core/rolling/FixedWindowRollingPolicy.html 
> 
> http://logback.qos.ch/apidocs/ch/qos/logback/core/rolling/TimeBasedRollingPolicy.html 
> 
> 
> If you run into problems, please let us know.
> 
> 
> At 08:24 PM 9/14/2006, Samuel Doyle wrote:
>> Hi, using this it is now complaining about a triggeringpolicy.
>>
>> INFO in ch.qos.logback.core.joran.action.AppenderAction - About to 
>> instantiate appender of type 
>> [ch.qos.logback.core.rolling.RollingFileAppender]
>> INFO in ch.qos.logback.core.joran.action.AppenderAction - Appender 
>> named as [bitranlog]
>> ERROR in ch.qos.logback.core.joran.action.NestedComponentIA - Could 
>> not create component <rollingPolicy>.
>> WARN in ch.qos.logback.core.rolling.RollingFileAppender[bitranlog] - 
>> Please set a TriggeringPolicy for the RollingFileAppender named bitranlog
>> INFO in ch.qos.logback.core.joran.action.AppenderAction - Popping 
>> appender named [bitranlog] from the object stack
> 

-- 
Sébastien Pennec
sebastien at qos.ch

Logback: The reliable, generic, fast and flexible logging framework for Java.



More information about the Logback-user mailing list