[logback-user] How to create log files per log level

lunch716 at yahoo.co.jp lunch716 at yahoo.co.jp
Tue Oct 12 21:13:16 CEST 2010


Hi, I found the solution.

<appender name="ERROR" 	
class="ch.qos.logback.core.rolling.RollingFileAppender">
 <filter class="ch.qos.logback.classic.filter.LevelFilter">
   <level>ERROR</level>
   <onMatch>ACCEPT</onMatch>
   <onMismatch>DENY</onMismatch>
 </filter>
 <Encoding>UTF-8</Encoding>
 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
 <FileNamePattern>error.%d{yyyy-MM-dd}.log</FileNamePattern>
 </rollingPolicy>
 <layout class="ch.qos.logback.classic.PatternLayout">
 <Pattern><![CDATA[%-4relative [%thread] %-5level %logger{30} -
%msg%n]]></Pattern>
 </layout>
</appender>
 
<root>
 <appender-ref ref="ERROR" />
</root>

Thnaks.

--- lunch716 at yahoo.co.jp wrote:

> Hi,
> 
> I'm using logback core and classic(both version are 0.9.9) with
> jdk5.0.
> My goal is to generate a log file per log level.Namely error.log is
> for
> error level and warn.log is for warn level and so on.
> 
> I found the following thread though,  
> 
> http://marc.info/?l=logback-user&m=125052059800553&w=2
> 
> I could not create the LevelBasedDiscriminator class because I could
> not
> find the classes below on logback 0.9.9.
> 
> ch.qos.logback.classic.sift.SiftingAppender
> ch.qos.logback.core.sift.Discriminator
> ch.qos.logback.classic.spi.ILoggingEvent
> 
> I have two questions.
> Q1.Is it possible to create log files per log level?
> Q2.If I have to give up the use of SiftingAppender,how can I
> accomplish my
> goal?
> 
> 
> --------------------------------------
> Learn more about breast cancer - Pink Ribbon Campaign 2010
> http://yj.pn/JAy9L7
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
> 


--------------------------------------
Learn more about breast cancer - Pink Ribbon Campaign 2010
http://yj.pn/JAy9L7


More information about the Logback-user mailing list