Where to put the log4j.properties file for tomcat6 java applications?

I am trying to configure logging for a RESTful / jax-rs java application. The application is functioning correctly, but I cannot configure logging. in my code I have:

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

and I put the usual log4j.properties in WebContent / WEB-INF /, but when I run tomcat with this application, 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 put the file? Sorry if this is a question n00b, but it lashes out for a while.

+4
source share
1 answer

Put it with the application code in / WEB -INF / classes, log4j expects to find it in the classpath. And you do not need to call the configurator, which happens automatically.

+9
source

All Articles