Wednesday, December 7, 2011 log4j.xml (No such file or directory)

If you get below mentioned error

log4j:ERROR Could not parse url [file:log4j.xml]. log4j.xml (No such file or directory)
        at Method)
        at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
        at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(
        at org.apache.log4j.xml.DOMConfigurator$2.parse(
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(
        at org.apache.log4j.xml.DOMConfigurator.doConfigure(
        at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(
        at org.apache.log4j.LogManager.(
        at org.slf4j.impl.Log4jLoggerFactory.getLogger(
        at org.slf4j.LoggerFactory.getLogger(
        at org.slf4j.LoggerFactory.getLogger(
        at org.quartz.impl.StdSchedulerFactory.(

Possible reason could be JVM is not able to find the provided file log4j.xml. Make sure the file is present in the location and You could pass the file in command line as shown below.

java -Dlog4j.configuration=file:/home/log4j.xml com.TestJava

OR add directly in your Java code.

System.setProperty("log4j.configuration", "/home/log4j.xml");

If you are using Eclipe IDE you can pass through VM arguments by steps shown below

Right click on Java -> Run As -> Run Configurations.. -> Arguments tab -> VM arguments

add the below code


Apply -> Run

No comments:

Post a Comment