简体   繁体   English

如何为Web应用程序配置log4j.xml?

[英]How do I configure log4j.xml for a web app?

I am trying to run a java application on webLogic and I use log4j. 我试图在webLogic上运行Java应用程序,并且使用log4j。 I put the log4j.xml in WebContent/WEB-INF both eclipse and webLogic server(when i try to run the application on the server and eclipse in problems) say that A DOCTYPE is not allowed in content. 我将eclipse和webLogic服务器中的log4j.xml都放在了WebContent / WEB-INF中(当我尝试在服务器上运行应用程序并解决问题时)时,我说内容中不允许使用DOCTYPE。 I understand the problem comes from the log4j.xml containing the first line below: 我理解问题来自包含以下第一行的log4j.xml:

<element><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"></element>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
...
</log4j:configuration>

. Is the log4j.xml not supposed to be placed in WebContent folder? log4j.xml是否不应该放置在WebContent文件夹中? is there another way to configure log4j not using !DOCTYPE? 还有另一种不使用!DOCTYPE来配置log4j的方法吗?

Your XML is not really XML (so you don't even need to look at the log4j stuff). 您的XML并不是真正的XML(因此您甚至无需查看log4j内容)。

Doctypes must be declared before the body of the XML document. 必须在XML文档的主体之前声明Doctypes。 You have it in the middle of the "element" tag. 您将其放在“元素”标记的中间。 By placing the doctype in the middle of a tag, the document "becomes" not XML. 通过将doctype放在标签的中间,文档“成为” XML而不是“ XML”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM