tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Problem with using log4j Tomcat and web application level
Date Mon, 17 Sep 2012 16:31:31 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Izolda,

On 9/16/12 6:19 AM, Kiss Izolda wrote:
> I have configured Tomcat to use log4j according to 
> http://tomcat.apache.org/tomcat-7.0-doc/logging.html I have used
> the same log4j.properties. My web application is using log4j as
> well. There is no log4j.jar in WEB-INF/lib.

You need to put one in there if you want application-level logging to
work the way you expect.

> How can I prevent Tomcat from using the web application's root
> logger?

Tomcat will not use the web application's logger if you configure the
two logging systems separately. You need:

- - log4j.jar in CATALINA_BASE/lib (for Tomcat's logging)
- - log4j.xml in CATALINA_BASE/lib (for Tomcat's logging config)
- - log4j.jar in webapp's WEB-INF/lib (for app logging)
- - log4j.xml in webapp's WEB-INF/lib (for app logging config)

Also, remember that you have to trigger a configuration operation
before you try to use the logger in your webapp, so make sure you do
that. I'm not sure how to trigger an XML configuration, but for a
property-file-based config, you just have to instantiate a new
"PropertyConfigurator" object. You can probably do something similar
for an XML-based configuration.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBXUGMACgkQ9CaO5/Lv0PCHbwCgi3OM1T1yZlQQdEktcV1+q3Zw
gb4AoKDupX+E2n9YxZq9OnaEdhAE9HiE
=2csn
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message