简体   繁体   中英

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

I'm trying to configure logging for a RESTful / jax-rs java app. 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: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.

Put it with your application code under /WEB-INF/classes, log4j expects to find it in the classpath. And you don't need to call the configurator, that happens automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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