简体   繁体   English

在tomcat6 java应用程序中放置log4j.properties文件的位置?

[英]where to put log4j.properties file for tomcat6 java apps?

I'm trying to configure logging for a RESTful / jax-rs java app. 我正在尝试为RESTful / jax-rs java应用程序配置日志记录。 The app functions correctly, but I can't get logging configured. 该应用程序正常运行,但我无法配置日志记录。 in my code I have: 我的代码中有:

private static Logger logger = Logger.getLogger(Foo.class); static { PropertyConfigurator.configure("log4j.properties"); }

and i have put the usual log4j.properties in WebContent/WEB-INF/, but when I start tomcat with this app, I get in catalina.out: 我把通常的log4j.properties放在WebContent / WEB-INF /中,但是当我用这个应用程序启动tomcat时,我进入了catalina.out:

log4j:ERROR Could not read configuration file [log4j.properties]. java.io.FileNotFoundException: log4j.properties (No such file or directory)

where else can i possibly put the file? 我还可以把文件放在哪里? sorry if this is a n00b question, but this has been stumping me for a while. 对不起,如果这是一个n00b问题,但这已经让我感到困惑了一段时间。

Put it with your application code under /WEB-INF/classes, log4j expects to find it in the classpath. 把它放在/ WEB-INF / classes下的应用程序代码中,log4j希望在类路径中找到它。 And you don't need to call the configurator, that happens automatically. 而且您不需要调用配置器,这会自动发生。

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

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