Cla*_* MG 8 java logging log4j2
我正在测试Log4j2,我不知道我做错了什么,因为我从Apache下载了库并将它们放在了类路径中.我也添加了xercesImpl,xalan,xml-apis,serializer,xsltc,但异常仍然存在.我显示堆栈跟踪和配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Properties>
<Property name="log-path">C:/Logs/</Property>
</Properties>
<Appenders>
<RollingFile name="RollingFile" fileName="${log-path}/myexample.log"
filePattern="${log-path}/myexample-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="1 KB" />
</Policies>
<DefaultRolloverStrategy max="4" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="root" level="debug" additivity="false">
<appender-ref ref="RollingFile" level="debug" />
</Logger>
<Root level="debug" additivity="false">
<AppenderRef ref="RollingFile" />
</Root>
</Loggers>
</Configuration>
ERROR StatusLogger Error parsing C:\W7des\cliente\Test\bin\log4j2.xml javax.xml.parsers.ParserConfigurationException: Feature 'http://apache.org/xml/features/xinclude' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.newDocumentBuilder(Unknown Source)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:85)
at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:137)
at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:44)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:472)
at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:442)
at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:254)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:419)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:207)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:160)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:492)
at pac.Main.<clinit>(Main.java:14)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
Run Code Online (Sandbox Code Playgroud)
提前致谢.
Tho*_*ler 10
在我的例子中,xercesImpl-2.6.2.jar从类路径中删除过时的帮助.
Oracle JVM 附带一个支持 XInclude 的 XML 解析器。根据此文档http://www-03.ibm.com/systems/resources/sdkguide.zos.pdf,IBM J9 VM 还捆绑了一个支持 XInclude 的 XML 解析器(请参阅第 21 页 XML4J 4.5)。
我不确定是否有必要使用单独的 XML 解析器(您提到您正在使用 Xerces 而不是与 JVM 捆绑在一起的 XML 解析器)。您使用什么版本的 Xerces/Xalan?如果从类路径中删除自定义 XML 解析器会发生什么?
顺便说一下,如果 Log4j 无法启用 XInclude,它将输出 WARN 级别的 StatusLogger 消息。您是否收到任何以“The DocumentBuilderFactory...”开头的 WARN 级别 StatusLogger 消息?请在您的问题中包含这些消息。
不幸的是,目前 Log4j 中没有开关来阻止它尝试启用 XInclude 功能。我怀疑上面的问题是配置问题,但如果无法解决,您可以请求将此类开关添加为新的 Log4j 功能。解决这个问题的地方是 Log4j Jira 问题跟踪器。