首页 > 代码库 > 项目中用到的logback列子

项目中用到的logback列子

转自: 项目中用到的logback列子

 

某个银行项目中实际引用的Llogback实例,禁提供大家参考!!!!

<!-- if debug set to true, context info always print
 otherwise the contex info will print when error occour -->
<configuration scan="true" scanPeriod="60 seconds" debug="false"> 

  <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">  
     <layout class="ch.qos.logback.classic.PatternLayout">  
       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>  
     </layout>  
   </appender>  
 
 <!-- 所有日志文件-->
 <appender name="AllLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
   <fileNamePattern>log/abcchina/all/%d{yyyy-MM-dd}.log</fileNamePattern> 
   <maxHistory>30</maxHistory> 
  </rollingPolicy> 
  <encoder> 
   <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern> 
  </encoder> 
 </appender>
 
 <appender name="TaskLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
   <fileNamePattern>log/abcchina/task/%d{yyyy-MM-dd}.log</fileNamePattern> 
   <maxHistory>30</maxHistory>
  </rollingPolicy> 
  <encoder> 
   <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern> 
  </encoder> 
 </appender>
 <appender name="SendLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
  <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
   <fileNamePattern>log/abcchina/send/%d{yyyy-MM-dd}.log</fileNamePattern> 
   <maxHistory>30</maxHistory>
  </rollingPolicy> 
  <encoder> 
   <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern> 
  </encoder> 
 </appender>
 <!-- 为莫个包下的所有类指定Appender 这里也可以指定类名称例如:com.aa.bb.ClassName-->  
 <logger name="com.aa.bb" >
  <appender-ref ref="TaskLog" />
 </logger>
 
 <logger name="com.aa.cc" >
  <appender-ref ref="SendLog" />
 </logger>
 
 <root level="INFO"> 
  <appender-ref ref="AllLog" />
 </root> 
</configuration>

 


 


 

项目中用到的logback列子