Thanks for your reply Chris.

On Mon, Jan 27, 2014 at 12:40 PM, Christopher Schultz <
ch...@christopherschultz.net> wrote:

> Are you running one and only one webapp in your Tomcat instance? If
> not, then the system property will override it for all webapps, which
> will probably cause confusion (especially if log4j.jar is in the
> webapp's WEB-INF/lib directory, since log4j will be initialized more
> than once).


For this use case, I'm only running one webapp per tomcat instance.  Good
reminder though about confusion in the case of multiple webapps.


> Where exactly in the "class path"?
>

I've tried both specifying it as an -cp argument when executing the
webapp-runner and including it in the WAR file WEB-INF/lib


> How are you initializing log4j itself? In a ServletContextListener or
> something similar? Do you manually call "new PropertyConfiguration()"
> or something like that? If so, why not simply put log4j.properties
> into WEB-INF/classes and remove the system property? I think that will
> simplify things and likely work better.
>

I'm simply initializing the logger inside the servlet, e.g.

static Logger log = Logger.getLogger(HelloWorldExample.class);

You're right though, I can put the log4j.properties file in WEB-INF/classes
and that works.  It's just that in this case being able to override the
logging properties when executing the webapp-runner would have been
convenient.


--john

Reply via email to