java “log4j:configuration”必须匹配“(renderer....loggerFactory)?)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12321943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
“log4j:configuration” must match “(renderer….loggerFactory)?)”
提问by Jaanus
getting error, when deploying my war file to tomcat:
将我的War文件部署到 tomcat 时出现错误:
log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,throwableRenderer?,appender*,plugin*,(category|logger)*,root?,(categoryFactory|loggerFactory)?)"
I googled around and found out that ordering of my log4j.xml could be wrong, but it should be correct.
我搜索了一下,发现我的 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 %d %c %x - %m%n"/>
</layout>
</appender>
<root>
<priority value ="error" />
<appender-ref ref="console" />
</root>
<category name="org.springframework" additivity="false">
<priority value="info" />
<appender-ref ref="console" />
</category>
</log4j:configuration>
Any suggestions?
有什么建议?
回答by Ian Roberts
According to the error message, the DTD expects all category
elements to be ahead of the root
element. You have them the wrong way round.
根据错误消息,DTD 期望所有category
元素都在root
元素之前。你把它们弄错了。
回答by Aioria de Leo
Follow this order:
按照这个顺序:
<renderer></renderer>
<appender></appender>
<plugin></plugin>
<logger></logger>
<category></category>
<root></root>
<loggerfactory></loggerfactory>
<categoryfactory></categoryfactory>