Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I added the xercesImpl, xalan, xml-apis, serializer, xsltc too and the exception still persist. 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.

like image 253
Clara MG Avatar asked Jan 09 '15 12:01

Clara MG


People also ask

What is Apache Log4j 2 used for?

Starting with version 2.4, Log4j 2 provides an API for programmatic configuration The new ConfigurationBuilder API allows you to create Configurations in code by constructing component definitions without requiring you to know about the internals of actual configuration objects like Loggers and Appenders.

Where can I find the Log4j configuration file?

During Content Engine installation, two log4j sample files are placed on the system in the ContentEngine\config\samples\ folder: log4j. properties. client: A Java format file that contains client configuration settings.

What is configuration status in LOG4J2 XML?

Configuration: the root element of a log4j2 configuration file; the status attribute represents the level at which internal log4j events should be logged. Appenders: this element contains a list of appenders; in our example, an appender corresponding to the System console is defined.

Where does LOG4J2 XML go?

We should put log4j2. xml anywhere in the application's classpath. Log4j will scan all classpath locations to find out this file and then load it. We can find this file mostly placed in the 'src/main/resources' folder.


1 Answers

In my case, removing an outdated xercesImpl-2.6.2.jar from the classpath helped.

like image 126
Thomas Weller Avatar answered Sep 18 '22 15:09

Thomas Weller