Eclipse:在log4j.xml中引用log4j.dtd [英] Eclipse: Referencing log4j.dtd in log4j.xml

查看:958
本文介绍了Eclipse:在log4j.xml中引用log4j.dtd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用log4j了一段时间,我通常使用这个在log4j.xml的顶部(可能就像许多其他人,根据谷歌这是方式it):

I've been using log4j for quite a while now and I usually use this at the top of the log4j.xml (probably just like many others and according to Google this is the way to do it):

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

显然这是可行的,但Eclipse不提供其上下文敏感的帮助,所有。此外,它总是显示一个警告,它没有找到 log4j.dtd 。现在我很好奇如何解决这个问题。

Obviously this is working, however Eclipse doesn't provide its context-sensitive help for writing the XML and all. Furthermore, it always shows a warning that it doesn't find the log4j.dtd. Now I'm curious how to fix this.

我尝试了几件事,这些工作:

I tried a few things and these work:

<!DOCTYPE log4j:configuration SYSTEM "jar:file:/path/.m2/repository/log4j/log4j/1.2.14/log4j-1.2.14.jar!/org/apache/log4j/xml/log4j.dtd">
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">

正如你从上面可以看到的,我们使用Maven。因此,我试过这个,但它失败:

As you can see from above we're using Maven. Therefore, I tried this, but it fails:

<!DOCTYPE log4j:configuration SYSTEM "jar:file:${M2_REPO}/log4j/log4j/1.2.14/log4j-1.2.14.jar!/org/apache/log4j/xml/log4j.dtd">

Eclipse通常知道如何处理类路径变量,但为什么不工作?我知道引用在运行时不会工作,但也不是一个简单的 log4j.dtd (如果我没有错),所以应该不是一个问题

Eclipse usually knows how to deal with the classpath variables, but why doesn't this work? I know that the reference won't work during runtime, but neither does a simple log4j.dtd (if I'm not wrong), so that shouldn't be a problem.

任何人都可以看到这个吗?

Can anyone please shed a light on this?

推荐答案

我知道这个问题已经回答,但我想提供我稍微不同的选择:

I know this question has been answered, but I'd like to provide my slightly different alternative:

<!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">

它类似于 @ FrVaBe的回应,但在正面,不需要任何进一步的Eclipse配置(例如,如果你与他人共享你的项目,或有一个大团队,这是一件小事要担心)。

It is similar to @FrVaBe's response, but on the plus side, does not require any further Eclipse configuration (i.e., if you're sharing your project with others, or have a large team, it's one less thing to worry about).

不过,我相信这意味着你需要一个互联网连接(至少在开发的某个阶段,即使只是一次)。

The down side though, is that I believe it means you'll need an Internet connection (at least at some point during development, even if it's just one time).

这篇关于Eclipse:在log4j.xml中引用log4j.dtd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆