鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 手机系统开发 > J2ME > >

log4j xml模式配置

来源:互联网 作者:佚名 时间:2015-09-25 05:48
Xml代码 ? xml version = 1.0 encoding = UTF-8 ? !DOCTYPElog4j:configurationSYSTEMlog4j.dtd log4j:configuration xmlns:log4j = http://jakarta.apache.org/log4j/ debug = false !--控制台输出日志-- appender name = CONSOLE class = org.apache.log4j
Xml代码  收藏代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">  
  3. <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">  
  4.   
  5.     <!-- 控制台输出日志 -->  
  6.     <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">  
  7.         <param name="Threshold" value="INFO"/>  
  8.         <param name="Target" value="System.out"/>  
  9.         <layout class="org.apache.log4j.PatternLayout">  
  10.             <param name="ConversionPattern" value="%d{yyyy-MM-dd HH\:mm\:ss} [%p] %m%n"/>  
  11.         </layout>  
  12.         <filter class="org.apache.log4j.varia.LevelRangeFilter">  
  13.             <param name="LevelMin" value="INFO"/>  
  14.             <param name="LevelMax" value="ERROR"/>  
  15.         </filter>  
  16.     </appender>  
  17.   
  18.     <!-- info至error 级别日志 -->  
  19.     <appender name="INFO_ERROR" class="org.apache.log4j.RollingFileAppender">  
  20.         <param name="File" value="/home/logs/pfmms/info_error.log"/>  
  21.         <param name="Append" value="true"/>  
  22.         <param name="MaxFileSize" value="20MB"/>  
  23.         <param name="Threshold" value="INFO"/>  
  24.         <param name="MaxBackupIndex" value="10"/>  
  25.         <layout class="org.apache.log4j.PatternLayout">  
  26.             <param name="ConversionPattern" value="%d{yyyy-MM-dd HH\:mm\:ss} [%p] %m%n"/>  
  27.         </layout>  
  28.         <filter class="org.apache.log4j.varia.LevelRangeFilter">  
  29.             <param name="LevelMin" value="INFO"/>  
  30.             <param name="LevelMax" value="ERROR"/>  
  31.         </filter>  
  32.     </appender>  
  33.       
  34.     <!-- debug级别日志 -->  
  35.     <appender name="DEBUG_LOG" class="org.apache.log4j.RollingFileAppender">  
  36.         <param name="Threshold" value="DEBUG"/>  
  37.         <param name="File" value="/home/logs/pfmms/debug.log"/>  
  38.         <param name="Append" value="true"/>  
  39.         <param name="MaxFileSize" value="20MB"/>  
  40.         <param name="MaxBackupIndex" value="10"/>  
  41.         <layout class="org.apache.log4j.PatternLayout">  
  42.             <param name="ConversionPattern" value="%d{yyyy-MM-dd HH\:mm\:ss} [%p] %m%n"/>  
  43.         </layout>  
  44.         <filter class="org.apache.log4j.varia.LevelRangeFilter">  
  45.             <param name="LevelMin" value="DEBUG"/>  
  46.             <param name="LevelMax" value="DEBUG"/>  
  47.         </filter>  
  48.     </appender>  
  49.       
  50.     <!-- error级别日志  -->  
  51.     <appender name="ERROR_LOG" class="org.apache.log4j.RollingFileAppender">  
  52.         <param name="Threshold" value="ERROR"/>  
  53.         <param name="File" value="/home/logs/pfmms/error.log"/>  
  54.         <param name="Append" value="true"/>  
  55.         <param name="MaxFileSize" value="20MB"/>  
  56.         <param name="MaxBackupIndex" value="10"/>  
  57.         <layout class="org.apache.log4j.PatternLayout">  
  58.             <param name="ConversionPattern" value="%d{yyyy-MM-dd HH\:mm\:ss} [%p] %m%n"/>  
  59.         </layout>  
  60.         <filter class="org.apache.log4j.varia.LevelRangeFilter">  
  61.             <param name="LevelMin" value="ERROR"/>  
  62.             <param name="LevelMax" value="ERROR"/>  
  63.         </filter>  
  64.     </appender>  
  65.   
  66.     <!--设置sql包的输出级别-->    
  67.     <category name="java.sql" additivity="true">    
  68.         <priority value="DEBUG" />  
  69.         <appender-ref ref="CONSOLE"/>  
  70.     </category>    
  71.   
  72.     <root>  
  73.         <!-- 优先级 -->  
  74.         <priority value="INFO"/>  
  75.         <appender-ref ref="CONSOLE"/>  
  76.         <appender-ref ref="INFO_ERROR"/>  
  77.         <appender-ref ref="DEBUG_LOG"/>  
  78.         <appender-ref ref="ERROR_LOG"/>  
  79.     </root>  
  80.   
  81. </log4j:configuration>  
 
网友评论
<