[logback-user] Best Practice to Setup Multiple Log Files for Multiple Classes
Chris Pratt
thechrispratt at gmail.com
Thu Oct 11 01:38:21 CEST 2012
I don't typically use the XML format for my log config, but that looks
right. Are you sure it's loading that configuration file?
(*Chris*)
On Wed, Oct 10, 2012 at 4:29 PM, Dan Franks <dan.franks at gmail.com> wrote:
> I was trying this but then all the logging from all the classes wrote
> to all the files.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <configuration scan="true" scanPeriod="30 seconds">
>
>
> <appender name="com.myCompany.orangeClassFileAppender"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <append>true</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>info</level>
> </filter>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <fileNamePattern>c.m.orangeClass.%d{yyyy-MM-dd}</fileNamePattern>
> </rollingPolicy>
>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss}, %p, %c, %t, %C{1}, %M
> %m%n</pattern>
> </layout>
> </appender>
>
>
>
>
>
>
> <appender name="com.myCompany.purpleClassFileAppender"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <append>true</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>info</level>
> </filter>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <fileNamePattern>c.m.purpleClass.%d{yyyy-MM-dd}</fileNamePattern>
> </rollingPolicy>
>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss}, %p, %c, %t, %C{1}, %M
> %m%n</pattern>
> </layout>
> </appender>
>
>
>
>
>
>
> <appender name="com.myCompany.greenClassFileAppender"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <append>true</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>debug</level>
> </filter>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>
> <fileNamePattern>c.m.greenClass.Loader.%d{yyyy-MM-dd}</fileNamePattern>
> </rollingPolicy>
>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss}, %p, %c, %t, %C{1}, %M
> %m%n</pattern>
> </layout>
> </appender>
>
>
>
>
>
>
>
> <appender name="RootFileAppender"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <append>true</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>info</level>
> </filter>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <fileNamePattern>c.m.default.%d{yyyy-MM-dd}</fileNamePattern>
> </rollingPolicy>
>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss}, %p, %c, %t, %C{1}, %M
> %m%n</pattern>
> </layout>
> </appender>
>
>
>
>
>
> <logger additivity="false" name="com.myCompany.orangeClass">
> <level value="info"/>
> <appender-ref ref="com.myCompany.orangeClassFileAppender"/>
> </logger>
> <logger additivity="false" name="com.myCompany.purpleClass">
> <level value="info"/>
> <appender-ref ref="com.myCompany.purpleClassFileAppender"/>
> </logger>
> <logger additivity="false" name="com.myCompany.greenClass">
> <level value="debug"/>
> <appender-ref ref="com.myCompany.greenClassFileAppender"/>
> </logger>
>
> <root><level value="info"/>
> <appender-ref ref="RootFileAppender"/>
> </root>
>
> </configuration>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20121010/3349668a/attachment-0001.html>
More information about the Logback-user
mailing list