我有小問題,我的log4j.xml配置步驟如下問題的log4j的XML配置
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{1} - %m%n" />
</layout>
</appender>
<logger name="com.alsodeep">
<level value="info" />
<appender-ref ref="console" />
</logger>
<logger name="org.springframework">
<level value="error" />
<appender-ref ref="console" />
</logger>
<root>
<priority value="error" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
,當我調用log.info的com.alsodeep封裝內部(「一些信息」)它印出兩次,例如
INFO AspectExample - Call it before method
INFO AspectExample - Call it before method
Hello
INFO AspectExample - Call it after method
INFO AspectExample - Call it after method
List content [[23, 243, 234, 23432]]
INFO App - final
INFO App - final
我很困惑這個,我的log4j設置有什麼問題。
PS當我從根元素中刪除appender時,一切正常,我的日誌信息只出現一次。
謝謝,它真的很有幫助 –