简体   繁体   English

问题http://apache.org/xml/features/xinclude测试log4j 2

[英]Issue http://apache.org/xml/features/xinclude testing log4j 2

I'm testing Log4j2 and I don't know what I'm doing wrong because I downloaded the library from Apache and put them in the classpath. 我正在测试Log4j2,我不知道我做错了什么,因为我从Apache下载了库并将它们放在了类路径中。 I added the xercesImpl, xalan, xml-apis, serializer, xsltc too and the exception still persist. 我也添加了xercesImpl,xalan,xml-apis,serializer,xsltc,但异常仍然存在。 I show the stack trace and the config file: 我显示堆栈跟踪和配置文件:

<?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)

Thanks in advance. 提前致谢。

在我的例子中,从类路径中删除过时的xercesImpl-2.6.2.jar有帮助。

Worked for me after removing xerces directory from gradle caches. 从gradle缓存中删除xerces目录后为我工作。

cd ~/.gradle/caches/modules-2/files-2.1
rm -rf xerces

The Oracle JVM comes with an XML parser that supports XInclude. Oracle JVM附带了一个支持XInclude的XML解析器。 According the this doc http://www-03.ibm.com/systems/resources/sdkguide.zos.pdf the IBM J9 VM also bundles an XML parser that supports XInclude (see page 21 XML4J 4.5). 根据此文档http://www-03.ibm.com/systems/resources/sdkguide.zos.pdf,IBM J9 VM还捆绑了一个支持XInclude的XML解析器(参见第21页XML4J 4.5)。

I am not sure if it is necessary to use a separate XML parser (you mentioned you are using Xerces instead of the XML parser bundled with the JVM). 我不确定是否有必要使用单独的XML解析器(您提到您使用的是Xerces而不是与JVM捆绑在一起的XML解析器)。 What version of Xerces/Xalan are you using? 您使用的是什么版本的Xerces / Xalan? What happens if you remove the custom XML parsers from the classpath? 如果从类路径中删除自定义XML解析器会发生什么?

By the way, Log4j will output WARN-level StatusLogger messages if it cannot enable XInclude. 顺便说一下,如果Log4j无法启用XInclude,它将输出WARN级StatusLogger消息。 Are you getting any WARN-level StatusLogger messages that start with "The DocumentBuilderFactory..."? 您是否收到任何以“The DocumentBuilderFactory ...”开头的WARN级StatusLogger消息? Please include these messages in your question. 请在您的问题中包含这些消息。

Unfortunately there is currently no switch in Log4j to prevent it from trying to enable the XInclude function. 不幸的是,目前Log4j中没有开关来阻止它尝试启用XInclude功能。 I suspect the problem above is a configuration issue but if it cannot be resolved you can request that such a switch be added as a new Log4j feature. 我怀疑上面的问题是配置问题,但如果无法解决,您可以请求将此类交换机添加为新的Log4j功能。 The place for this is the Log4j Jira issue tracker . 这个地方是Log4j Jira问题跟踪器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当功能“http://apache.org/xml/features/disallow-doctype-decl”设置为true时,不允许获取DOCTYPE - Getting DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true Maven和GWT的Log4j问题:org.apache.log4j.XAppender对象不可分配 - Log4j issue with maven and gwt: org.apache.log4j.XAppender object is not assignable NoClassDefFoundError:org / apache / log4j / Logger - NoClassDefFoundError: org/apache/log4j/Logger 我的 log4j 问题 java.lang.ClassNotFoundException: =org.apache.log4j.RollingFileAppender - my Issue with log4j java.lang.ClassNotFoundException: =org.apache.log4j.RollingFileAppender log4j警告问题 - apache commons - log4j warning issue - apache commons log4j:WARN找不到记录程序的附加程序(org.apache.http.impl.conn.SingleClientConnManager) - log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.SingleClientConnManager) NoSuchMethodError: org/apache/log4j/Logger.setLevel(Lorg/apache/log4j/Level;) - NoSuchMethodError: org/apache/log4j/Logger.setLevel(Lorg/apache/log4j/Level;) java.lang.NoClassDefFoundError:org / apache / log4j / Priority - java.lang.NoClassDefFoundError: org/apache/log4j/Priority 如何解决 NoClassDefFoundError: org/apache/log4j/Logger in linux - How to resolve NoClassDefFoundError: org/apache/log4j/Logger in linux java.lang.NoClassDefFoundError:org / apache / log4j / PropertyConfigurator - java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM