标签:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="ERRORFILE" class="org.apache.log4j.ConsoleAppender"> <param name="Threshold" value="ERROR" /> <param name="File" value="F:/error.log" /> <param name="MaxFileSize" value="2000MB"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> </layout> </appender> <appender name="WELCOMEFILE" class="org.apache.log4j.RollingFileAppender"> <param name="Threshold" value="INFO" /> <param name="File" value="F:/welcome.log" /> <!-- 日志文件允许的最大字节数(默认是10M) --> <param name="MaxFileSize" value="2000MB"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" /> </layout> <!--过滤器设置输出的级别,只能记录INFO和WARN级别的日志--> <filter class="org.apache.log4j.varia.LevelRangeFilter"> <param name="levelMin" value="INFO" /> <param name="levelMax" value="WARN" /> <param name="AcceptOnMatch" value="true" /> </filter> </appender> <logger name="org.apache.commons.httpclient"> <level value="ERROR" /> </logger> <!-- 这里虽然定义了DEBUG级别,但是由于WELCOMEFILE定义的是INFO级别,所以在WELCOMEFILE中我们能看到的也都是INFO级别的日志 --> <logger name="com.dan.test"> <level value="DEBUG" /> <appender-ref ref="WELCOMEFILE" /> </logger> <root> <level value="ERROR" /> <appender-ref ref="ERRORFILE" /> <appender-ref ref="WELCOMEFILE" /> </root> </log4j:configuration>
标签:
原文地址:http://blog.csdn.net/dandan8866/article/details/45394883