log4j.xml file placement [duplicate]

2019-01-25 12:18发布

问题:

This question already has an answer here:

  • Where to place log4j.xml 6 answers

i have created a log4j util class where i'm picking up the file using

org.apache.log4j.xml.DOMConfigurator.configure("log4j.xml");

but when testing, it throws

log4j:ERROR Could not open [log4j.xml].
java.io.FileNotFoundException: log4j.xml (The system cannot find the file specified.)
 at java.io.FileInputStream.<init>(FileInputStream.java:112)
 at java.io.FileInputStream.<init>(FileInputStream.java:72)

Can anyone tell me where do i place the log4j.xml file?

回答1:

Put it on the classpath, in the root folder.



标签: logging log4j