You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Vishnu Priya Matha (JIRA)" <ji...@apache.org> on 2018/03/20 07:07:00 UTC

[jira] [Commented] (LOG4J2-2283) ParserConfigurationException when using log4j with junit

    [ https://issues.apache.org/jira/browse/LOG4J2-2283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16405896#comment-16405896 ] 

Vishnu Priya Matha commented on LOG4J2-2283:
--------------------------------------------

This issue happens only when I run junit as part of Apache Ant version 1.8.1

> ParserConfigurationException when using log4j with junit
> --------------------------------------------------------
>
>                 Key: LOG4J2-2283
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2283
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.10.0
>            Reporter: Vishnu Priya Matha
>            Priority: Major
>
> 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>



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)