log4j.dtd
I use log4j in most of the projects for logging and use XML based configuration. Most of the part in log4j.xml
is common and all we need to add appenders and loggers.
我在大多数项目中使用log4j进行日志记录,并使用基于XML的配置。 log4j.xml
大部分部分是通用的,我们需要添加添加器和记录器。
Recently Eclipse shown a warning in my log4j.xml file as below. However it had no effect on my project build or deployment.
最近,Eclipse在我的log4j.xml文件中显示了一个警告,如下所示。 但是,这对我的项目构建或部署没有影响。
The line that was throwing the error was:
引发错误的行是:
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
Usually Eclipse looks for log4j.dtd in classpath and it doesn’t find it there and hence the error. We can resolve this issue by providing URL for log4j.dtd file like below.
通常,Eclipse在类路径中查找log4j.dtd,但在那里找不到它,因此会出现错误。 我们可以通过为log4j.dtd文件提供URL来解决此问题,如下所示。
<!DOCTYPE log4j:configuration SYSTEM
"https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
Some other valid configuration through which we can resolve the warning is:
我们可以用来解决警告的其他有效配置是:
<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN"
"https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
That’s all for fixing this eclipse log4j xml error because of log4j.dtd location.
全部用于解决由于log4j.dtd位置而导致的eclipse log4j xml错误。
翻译自: https://www.journaldev.com/2244/eclipse-log4j-xml-log4j-dtd-cannot-validated-xml-definition
log4j.dtd