Where to put log4j.properties in a GWT web app

ant, classpath, gwt, log4j, tomcat

Solution

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.

So, simply create WEB-INF/classes directory and put it there, or pack it into your JAR.

See also Where should I put the log4j.properties file? - it could be useful.

Problem

I have the log4j.properties and another .properties file under src and it works deployed in gwt dev mode. 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. The JAR file gets copied into the WEB-INF folder in the war file. 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.

Original source

Related problems