简体   繁体   English

将 log4j.properties 放在 GWT web 应用程序中的位置

[英]Where to put log4j.properties in a GWT web app

I have the log4j.properties and another.properties file under src and it works deployed in gwt dev mode.我在 src 下有 log4j.properties 和 another.properties 文件,它在 gwt 开发模式下工作。 To build the war to launch to tomcat I use an ant script that compiles the.java classes and puts them in a JAR file.为了构建向 tomcat 发起的战争,我使用了一个 ant 脚本来编译 .java 类并将它们放入 JAR 文件中。 The JAR file gets copied into the WEB-INF folder in the war file. JAR 文件被复制到 war 文件的 WEB-INF 文件夹中。

The app runs fine when I don't use log4j but it can't find the properties file when I attempt to use log4j. All of the answers I see say WEB-INF/classes, but my project doesn't have a WEB-INF/classes directory, instead the JAR file that was copied to WEB-INF contains my projects classes.当我不使用 log4j 时应用程序运行良好,但当我尝试使用 log4j 时它找不到属性文件。我看到的所有答案都说 WEB-INF/classes,但我的项目没有 WEB- INF/classes 目录,而不是复制到 WEB-INF 的 JAR 文件包含我的项目类。

You have to put log4j.properties (or log4j.xml) file into directory or JAR that is considered by your servlet-container as resource in Classpath.您必须将 log4j.properties(或 log4j.xml)文件放入目录或 JAR 中,您的 servlet 容器将其视为类路径中的资源。

So, simply create WEB-INF/classes directory and put it there, or pack it into your JAR.因此,只需创建 WEB-INF/classes 目录并将其放在那里,或者将其打包到您的 JAR 中。

See also Where should I put the log4j.properties file?另请参阅我应该将 log4j.properties 文件放在哪里? - it could be useful. - 它可能有用。

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

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