当前位置: 首页 > 工具软件 > fix_log4j2 > 使用案例 >

log4j.dtd_Eclipse log4j.xml –无法将log4j.dtd验证为XML定义

越涵衍
2023-12-01

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大部分部分是通用的,我们需要添加添加器和记录器。

Eclipse log4j.xml –无法将log4j.dtd验证为XML定义 (Eclipse log4j.xml – log4j.dtd cannot be validated as the XML definition)

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 file cannot be validated as the XML definition “/Users/pankaj/workspace/MyProject/src/main/java/log4j.dtd (No such file or directory)” that is specified as describing the syntax of the file cannot be located.
由于无法找到指定为描述文件语法的XML定义“ /Users/pankaj/workspace/MyProject/src/main/java/log4j.dtd(无此类文件或目录)”,因此无法验证该文件。

The line that was throwing the error was:

引发错误的行是:

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

Eclipse log4j.xml的修复–无法将log4j.dtd验证为XML定义 (Fix for Eclipse log4j.xml – log4j.dtd cannot be validated as the XML definition)

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

 类似资料: