Logging with log4j.xml and "Run"

Anyone on the forum using log4j along with IDEA "Run" option. I'd like to use a simple ConsoleAppender to output log events from the "Run" (shift f10) feature of IDEA.

Here's the output I get:


log4j:WARN Parsing warning 2 and column 38
log4j:WARN URI was not reported to parser for entity
log4j:WARN Parsing warning 2 and column 38
log4j:WARN missing system ID, using log4j.dtd
log4j:ERROR Could not parse url .
gnu.xml.dom.DomEx: The operation violates XML Namespaces.
More Information: xmlns is reserved
Node Name: #document
at gnu.xml.dom.DomDocument.createAttributeNS(DomDocument.java:589)
at gnu.xml.dom.DomDocument.createAttribute(DomDocument.java:561)
at gnu.xml.dom.DomDocument.defaultAttributes(DomDocument.java:456)
at gnu.xml.dom.DomDocument.createElementNS(DomDocument.java:440)
at gnu.xml.pipeline.DomConsumer$Handler.startElement(DomConsumer.java:602)
at gnu.xml.dom.Consumer$Backdoor.startElement(Consumer.java:203)
at gnu.xml.pipeline.EventFilter.startElement(EventFilter.java:570)
at gnu.xml.pipeline.ValidationConsumer.startElement(ValidationConsumer.java:1177)
at gnu.xml.aelfred2.SAXDriver.startElement(SAXDriver.java:836)
at gnu.xml.aelfred2.XmlParser.parseElement(XmlParser.java:1037)
at gnu.xml.aelfred2.XmlParser.parseDocument(XmlParser.java:416)
at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:167)
at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:146)
at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:612)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:711)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:468)
at org.apache.log4j.LogManager.(LogManager.java:122) at org.apache.log4j.Logger.getLogger(Logger.java:104) at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229) at org.apache.commons.logging.impl.Log4JLogger.(Log4JLogger.java:65) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:540) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:413) at com.vailsys.dba.model.TableMain.]]>(TableMain.java:13)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:87)

3 comments

What does your log4j.xml file look like? It looks like it's badly formed.

0

The same XML file works from within Eclipse, or running from a command line with the java command.


]]>

0

Problem was with gnujaxp.jar. I included it in a JFreechart library configuration (module settings -> libraries). The gnujaxp.jar has a META-INF/services/javax.xml.parsers.DocumentBuilderFactory file, with the value gnu.xml.dom.JAXPFactory. Evidently this parser does not like log4j.xml. I removed the jar from libraries, added -Djaxp.debug=1 to my Application's VM arguments and now see the following:

JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@133056f

and log statements appear in the console, or where ever else I want them.



-Dave

0

Please sign in to leave a comment.