logback

详细参考这篇博客:http://aub.iteye.com/blog/1103685

  

  
  
  


  
<configuration scan="true" scanPeriod="60 seconds" debug="false">  
      
    <property name="log_dir" value="/logs/ev_cmdb" />  
      
    <property name="maxHistory" value="30"/>  




      
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">  
          
        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%npattern>  
        encoder>  
    appender>  


      
      
    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">  
          
        <filter class="ch.qos.logback.classic.filter.LevelFilter">  
            <level>ERRORlevel>  
            <onMatch>ACCEPTonMatch>  
            <onMismatch>DENYonMismatch>  
        filter>  
          
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
              
            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/error-log.logfileNamePattern>  
              
            <maxHistory>${maxHistory}maxHistory>  
        rollingPolicy>  

          
          

        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%npattern>  
        encoder>  
    appender>  



      
    <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">  
          
        <filter class="ch.qos.logback.classic.filter.LevelFilter">  
            <level>WARNlevel>  
            <onMatch>ACCEPTonMatch>  
            <onMismatch>DENYonMismatch>  
        filter>  
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
              
            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/warn-log.log  
            fileNamePattern>  
              
            <maxHistory>${maxHistory}maxHistory>  
        rollingPolicy>  
        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%npattern>  
        encoder>  
    appender>  




      
    <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">  
          
        <filter class="ch.qos.logback.classic.filter.LevelFilter">  
            <level>INFOlevel>  
            <onMatch>ACCEPTonMatch>  
            <onMismatch>DENYonMismatch>  
        filter>  
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
              
            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/info-log.log  
            fileNamePattern>  
              
            <maxHistory>${maxHistory}maxHistory>  
        rollingPolicy>  
        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%npattern>  
        encoder>  
    appender>  




      
    <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">  
          
        <filter class="ch.qos.logback.classic.filter.LevelFilter">  
            <level>DEBUGlevel>  
            <onMatch>ACCEPTonMatch>  
            <onMismatch>DENYonMismatch>  
        filter>  
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
              
            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/debug-log.log  
            fileNamePattern>  
              
            <maxHistory>${maxHistory}maxHistory>  
        rollingPolicy>  
        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%npattern>  
        encoder>  
    appender>  




      
    <appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">  
          
        <filter class="ch.qos.logback.classic.filter.LevelFilter">  
            <level>TRACElevel>  
            <onMatch>ACCEPTonMatch>  
            <onMismatch>DENYonMismatch>  
        filter>  
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">  
              
            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/trace-log.log  
            fileNamePattern>  
              
            <maxHistory>${maxHistory}maxHistory>  
        rollingPolicy>  
        <encoder>  
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%npattern>  
        encoder>  
    appender>  

    <logger name="java.sql.PreparedStatement" value="DEBUG" />    
    <logger name="java.sql.Connection" value="DEBUG" />    
    <logger name="java.sql.Statement" value="DEBUG" />    
    <logger name="com.ibatis" value="DEBUG" />    
    <logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />    
    <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG"/>    
    <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" value="DEBUG" />    



      
    <root level="debug">  
          
        <appender-ref ref="STDOUT" />  
          
        <appender-ref ref="ERROR" />  
        <appender-ref ref="INFO" />  
        <appender-ref ref="WARN" />  
        <appender-ref ref="DEBUG" />  
        <appender-ref ref="TRACE" />  
    root>  
configuration> 

pom:

<dependency>
  <groupId>org.slf4jgroupId>
  <artifactId>slf4j-apiartifactId>
  <version>1.7.10version>
dependency>
<dependency>
  <groupId>ch.qos.logbackgroupId>
  <artifactId>logback-classicartifactId>
  <version>1.1.2version>
dependency>
<dependency>
  <groupId>ch.qos.logbackgroupId>
  <artifactId>logback-coreartifactId>
  <version>1.1.2version>
dependency> 

你可能感兴趣的:(其他,logback)