Problem http://apache.org/xml/features/xinclude testing log4j 2

I am testing Log4j2 and I donโ€™t know what I am doing wrong, because I downloaded the library from Apache and put them in the classpath. I added xercesImpl, xalan, xml-apis, serializer, xsltc, and the exception is still persisting. I show the stack trace and configuration 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.

+7
java logging log4j2
source share
3 answers

In my case, removing the deprecated xercesImpl-2.6.2.jar from the class path helped.

+8
source

Oracle JVM comes with an XML parser that supports XInclude. According to this document http://www-03.ibm.com/systems/resources/sdkguide.zos.pdf , the IBM J9 VM also associates an XML parser that supports XInclude (see Page 21 XML4J 4.5).

I'm not sure whether to use a separate XML parser (you mentioned that you use Xerces instead of the XML parser bundled with the JVM). What version of Xerces / Xalan are you using? What happens if you remove custom XML parsers from the class path?

By the way, Log4j displays WARN-level StatusLogger messages if it cannot enable XInclude. Do you receive any StatusLogger messages on WARN that start with "The DocumentBuilderFactory ..."? Please include these messages in your question.

Unfortunately, there is no switch in Log4j so that it does not try to enable the XInclude function. I suspect that the problem above is a configuration problem, but if it cannot be resolved, you may want to add such a switch as a new Log4j feature. The place for this is the Log4j Jira issue tracker .

0
source

Worked for me after removing the xerces directory from gradle caches.

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

All Articles