Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

tomcat

log4j

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.

like image 290
downer Avatar asked Jan 20 '23 02:01

downer


1 Answers

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.

like image 177
Nathan Hughes Avatar answered Jan 28 '23 14:01

Nathan Hughes