首页 > 代码库 > logj4.xml

logj4.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
 3 <log4j:configuration>
 4     <!--输出到控制台-->
 5     <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
 6         <param name="Threshold" value="http://www.mamicode.com/DEBUG"/>
 7         <layout class="org.apache.log4j.PatternLayout">
 8             <param name="ConversionPattern" value="http://www.mamicode.com/[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
 9         </layout>
10     </appender>
11 
12     <!--输出到文件(info)-->
13     <!--将生成“info.log.2014-06-11”这样的日志文件-->
14     <appender name="fileAppenderInfo" class="org.apache.log4j.DailyRollingFileAppender">
15         <param name="File" value="http://www.mamicode.com/${user.home}/logs/website/info.log" />
16         <param name="DatePattern" value="http://www.mamicode.com/.yyyy-MM-dd" />
17         <layout class="org.apache.log4j.PatternLayout">
18             <param name="ConversionPattern" value="http://www.mamicode.com/[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
19         </layout>
20         <filter class="org.apache.log4j.varia.LevelRangeFilter">
21             <param name="LevelMin" value="http://www.mamicode.com/INFO" />
22             <param name="LevelMax" value="http://www.mamicode.com/INFO" />
23         </filter>
24     </appender>
25 
26     <!--输出到文件(warn)-->
27     <appender name="fileAppenderWarn" class="org.apache.log4j.DailyRollingFileAppender">
28         <param name="File" value="http://www.mamicode.com/${user.home}/logs/website/warn.log" />
29         <param name="DatePattern" value="http://www.mamicode.com/.yyyy-MM-dd" />
30         <layout class="org.apache.log4j.PatternLayout">
31             <param name="ConversionPattern" value="http://www.mamicode.com/[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
32         </layout>
33 
34         <filter class="org.apache.log4j.varia.LevelRangeFilter">
35             <param name="LevelMin" value="http://www.mamicode.com/WARN" />
36             <param name="LevelMax" value="http://www.mamicode.com/WARN" />
37         </filter>
38     </appender>
39 
40     <!--输出到文件(error)-->
41     <appender name="fileAppenderError" class="org.apache.log4j.DailyRollingFileAppender">
42         <param name="File" value="http://www.mamicode.com/${user.home}/logs/website/error.log" />
43         <param name="DatePattern" value="http://www.mamicode.com/.yyyy-MM-dd" />
44         <layout class="org.apache.log4j.PatternLayout">
45             <param name="ConversionPattern" value="http://www.mamicode.com/[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
46         </layout>
47         <filter class="org.apache.log4j.varia.LevelRangeFilter">
48             <param name="LevelMin" value="http://www.mamicode.com/ERROR" />
49             <param name="LevelMax" value="http://www.mamicode.com/ERROR" />
50         </filter>
51     </appender>
52 
53     <!--屏蔽所有org.springframework.*输出的Debug(及以下)信息-->
54     <logger name="org.springframework">
55         <level value="http://www.mamicode.com/INFO"></level>
56     </logger>
57 
58     <root>
59         <level value="http://www.mamicode.com/ALL"/>
60         <appender-ref ref="consoleAppender" />
61         <appender-ref ref="fileAppenderInfo" />
62         <appender-ref ref="fileAppenderWarn" />
63         <appender-ref ref="fileAppenderError" />
64     </root>
65 </log4j:configuration>

 

logj4.xml