Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2283

ParserConfigurationException when using Log4j with oracle.xml.jaxp.JXDocumentBuilderFactory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.10.0
    • 2.11.1, 3.0.0
    • Core
    • None
    • Important

    Description

      I am using Junit 4.10 and log4j 2.10 versions. When I run the junit test, I am unable to get the logs and following is the error when I turn on the log4j debugging:

      ERROR StatusLogger Error parsing /scratch/log4j.xml
      javax.xml.parsers.ParserConfigurationException
      at oracle.xml.jaxp.JXDocumentBuilderFactory.setFeature(JXDocumentBuilderFactory.java:374)
      at org.apache.logging.log4j.core.config.xml.XmlConfiguration.setFeature(XmlConfiguration.java:213)
      at org.apache.logging.log4j.core.config.xml.XmlConfiguration.disableDtdProcessing(XmlConfiguration.java:205)
      at org.apache.logging.log4j.core.config.xml.XmlConfiguration.newDocumentBuilder(XmlConfiguration.java:194)
      at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:92)
      at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
      at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:239)
      at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:369)
      at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:260)
      at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:613)
      at org.apache.logging.log4j.core.LoggerContext.setConfigLocation(LoggerContext.java:603)
      at oracle.oki.service.SampleBaseTest.setUpClass(SampleBaseTest.java:113)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
      at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:422)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:931)
      at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:785)

      Following is how I setup my logging configuration:

      LoggerContext context = (LoggerContext) LogManager.getContext(false);
      File file = new File("/scratch/log4j.xml");

      // this will force a reconfiguration
      context.setConfigLocation(file.toURI());

      And the log4j.xml has following contents:

      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration monitorinterval="30" status="info" strict="true">
      <Properties>
      <Property name="filename">/scratch/CelsiusConverter.log</Property>
      </Properties>
      <Appenders>
      <Appender type="Console" name="Console">
      <target>System.err</target>
      <Layout type="PatternLayout" pattern="%d %p [%t] %m%n" />
      </Appender>
      <Appender type="Console" name="FLOW">
      <target>System.err</target>
      <Layout type="PatternLayout" pattern="%C{1}.%M %m %ex%n" />
      </Appender>
      <Appender type="File" name="File" fileName="${filename}">
      <Layout type="PatternLayout" pattern="%d %p %C{1.} [%t] %m%n" />
      </Appender>
      </Appenders>
      <Loggers>
      <Root level="trace">
      <AppenderRef ref="File" />
      </Root>
      </Loggers>
      </Configuration>

      Attachments

        Activity

          People

            Unassigned Unassigned
            vishnupriyam Vishnu Priya Matha
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: