log4j配置

chw0 2015-02-11

<?xml version="1.0" encoding="GB2312" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
     <appender name="con" class="org.apache.log4j.ConsoleAppender">
  <param name="Threshold" value="DEBUG"/> 
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%5p]-[%c] %m%n"/>
  </layout>
    </appender>
 
    <appender name="sql" class="org.apache.log4j.DailyRollingFileAppender">
  <param name="File" value="/export/home/itms/WEB/logs/sql/sql"/>
  <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
  <param name="Append" value="true"/>
  <layout class="org.apache.log4j.PatternLayout"> 
   <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} %m%n"/>
  </layout> 
  <filter class="org.apache.log4j.varia.LevelRangeFilter">
     <param name="levelMin" value="INFO" />
     <param name="levelMax" value="INFO" />      
     <param name="AcceptOnMatch" value="true" />
  </filter>
    </appender>

 <appender name="log" class="org.apache.log4j.DailyRollingFileAppender">
  <param name="File" value="/export/home/itms/WEB/logs/log/log"/>   
  <param name="DatePattern" value="'.'yyyy-MM-dd"/>
  <param name="Append" value="true"/>
  <layout class="org.apache.log4j.PatternLayout"> 
   <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} %m%n"/>
  </layout> 
  <filter class="org.apache.log4j.varia.LevelRangeFilter">
     <param name="levelMin" value="WARN" />
     <param name="levelMax" value="WARN" />      
     <param name="AcceptOnMatch" value="true" />
  </filter>
    </appender>

 <appender name="err" class="org.apache.log4j.DailyRollingFileAppender">
  <param name="File" value="/export/home/itms/WEB/logs/err/err"/>
  <param name="DatePattern" value="'.'yyyy-MM-dd"/>
  <param name="Append" value="true"/>
  <layout class="org.apache.log4j.PatternLayout"> 
   <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} [%5p]-[%c] %m%n"/>
  </layout> 
  <filter class="org.apache.log4j.varia.LevelRangeFilter">
     <param name="levelMin" value="ERROR" />
     <param name="levelMax" value="ERROR" />      
     <param name="AcceptOnMatch" value="true" />
  </filter>
    </appender>
 

    <root>
       <level value ="debug"/>
       <appender-ref ref="con"/>
       <appender-ref ref="sql"/>
       <appender-ref ref="log"/>
    <appender-ref ref="err"/>       
    </root>   

</log4j:configuration>


 

相关推荐