标签:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!-- in java cmd add -Dlog4j.configuration=logging.xml --> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="log.console" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %t %-5p %c{2} - %m%n" /> </layout> </appender> <appender name="log.file" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="日志输出路径/upchnSmartSms.log" /> <param name="Append" value="true" /> <param name="Encoding" value="UTF-8" /> <param name="DatePattern" value="‘.‘yyyy-MM-dd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %t %-5p %c{2} - %m%n" /> </layout> </appender> <category name="org.springframework" additivity="false"> <priority value="warn" /> <appender-ref ref="log.file" /> </category> <category name="org.hibernate" additivity="false"> <priority value="warn" /> <appender-ref ref="log.file" /> </category> <category name="com.ffcs" additivity="false"> <priority value="info" /> <appender-ref ref="log.file" /> </category> <root> <priority value="info" /> <appender-ref ref="log.file" /> </root> </log4j:configuration>
将配置文件中category的additivity属性置为false. 日志就不会重复打印了。
标签:
原文地址:http://my.oschina.net/u/1989867/blog/507737