logj4.xml
Posted 壹品轩
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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="DEBUG"/> 7 <layout class="org.apache.log4j.PatternLayout"> 8 <param name="ConversionPattern" value="[%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="${user.home}/logs/website/info.log" /> 16 <param name="DatePattern" value=".yyyy-MM-dd" /> 17 <layout class="org.apache.log4j.PatternLayout"> 18 <param name="ConversionPattern" value="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/> 19 </layout> 20 <filter class="org.apache.log4j.varia.LevelRangeFilter"> 21 <param name="LevelMin" value="INFO" /> 22 <param name="LevelMax" value="INFO" /> 23 </filter> 24 </appender> 25 26 <!--输出到文件(warn)--> 27 <appender name="fileAppenderWarn" class="org.apache.log4j.DailyRollingFileAppender"> 28 <param name="File" value="${user.home}/logs/website/warn.log" /> 29 <param name="DatePattern" value=".yyyy-MM-dd" /> 30 <layout class="org.apache.log4j.PatternLayout"> 31 <param name="ConversionPattern" value="[%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="WARN" /> 36 <param name="LevelMax" value="WARN" /> 37 </filter> 38 </appender> 39 40 <!--输出到文件(error)--> 41 <appender name="fileAppenderError" class="org.apache.log4j.DailyRollingFileAppender"> 42 <param name="File" value="${user.home}/logs/website/error.log" /> 43 <param name="DatePattern" value=".yyyy-MM-dd" /> 44 <layout class="org.apache.log4j.PatternLayout"> 45 <param name="ConversionPattern" value="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n"/> 46 </layout> 47 <filter class="org.apache.log4j.varia.LevelRangeFilter"> 48 <param name="LevelMin" value="ERROR" /> 49 <param name="LevelMax" value="ERROR" /> 50 </filter> 51 </appender> 52 53 <!--屏蔽所有org.springframework.*输出的Debug(及以下)信息--> 54 <logger name="org.springframework"> 55 <level value="INFO"></level> 56 </logger> 57 58 <root> 59 <level value="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的主要内容,如果未能解决你的问题,请参考以下文章