我正在使用 log4j-1.2.17 jar 版本,
启动应用程序时,我在控制台中收到以下错误
log4j:WARN Continuable parsing error 38 and column 24
log4j:WARN Attribute "ref" is required and must be specified for element type "appender-ref".
log4j:WARN Continuable parsing error 47 and column 12
log4j:WARN The content of element type "root" must match "(param*,(priority|level)?,appender-ref*)".
log4j:ERROR No appender named [] could be found.
这是我编辑后的 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 class="org.apache.log4j.RollingFileAppender" name="FILE">
<param value="D:\\Two\\test.log" name="File"/>
<param value="10" name="MaxBackupIndex"/>
<param value="200MB" name="MaxFileSize"/>
<layout class="org.apache.log4j.PatternLayout">
<param value="%d[%t] %-5p(%F:<%M>:%L)- %m%n" name="ConversionPattern"/>
</layout>
</appender>
<appender class="com.MyAppender" name="customAppen">
<layout class="org.apache.log4j.PatternLayout">
<param value="%d[%t] %-5p(%F:<%M>:%L)- %m%n" name="ConversionPattern"/>
</layout>
</appender>
<appender class="org.apache.log4j.AsyncAppender" name="asynchapp">
<param name="Blocking" value="false"/>
<appender-ref ref="customAppen"/>
</appender>
<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="asynchapp"/>
</root>
</log4j:configuration>