Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is Log4j trying to find log4j.dtd

Tags:

java

log4j

I'm getting an exception when I try to run my application (in eclipse) complaining about log4j.dtd. Am I meant to have a dtd file if I use the xml configuration for log4j?

Caused by: java.io.FileNotFoundException: 

    C:\data\workspace\LDICommon_Trunk\resources\log4j.dtd (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
like image 324
Charbel Avatar asked Feb 11 '11 12:02

Charbel


2 Answers

If you are using XML-based log4j, then yes, you will need the DTD file. Copy this DTD file into your workspace: http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd

Make sure it sits at the same directory as your log4j XML file.

like image 127
limc Avatar answered Sep 28 '22 03:09

limc


Check your log4j.xml it must be looking for log4j.dtd

<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">

Instead you can use:

<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

source

like image 31
Volodymyr Fedorchuk Avatar answered Sep 28 '22 02:09

Volodymyr Fedorchuk