tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Reich, Matthias" <>
Subject RE: log4j error
Date Sun, 18 Nov 2007 13:36:27 GMT

another approach is the use of a RepositorySelector.
- you rely on the container to provide the log4j classes and to install
a suitable RepositorySelector
(should happen as early as possible, e.g. in a ServerLifeCycleListener)
- each webapp can still provide it's own logging configuration
- the RepositorySelector may provide some fallback mechanism, i.e. use a
default Logger Repository in case the webapp does not provide it's own

I was once pointed to such a solution by the following article which
explains the mechanism in more detail:

- Matthias

-----Original Message-----
From: Caldarale, Charles R [] 
Sent: Saturday, November 17, 2007 1:16 AM
To: Tomcat Users List
Subject: RE: log4j error

> From: Steven Crosley [] 
> Subject: log4j error
> log4j:ERROR The class "org.apache.log4j.Appender" was loaded by
> log4j:ERROR [org.apache.catalina.loader.StandardClassLoader@cbf30e]  
> whereas object of type
> log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by  
> [WebappClassLoader

This situation was reported earlier today in a different thread.  The
problem there was due to the following set of factors:

1) log4j*.jar in both Tomcat's lib directory and the webapp's

2) classes from Tomcat's lib directory making references to log4j

3) classes from the webapp making references to log4j

4) classes from the webapp calling methods in classes from Tomcat's lib

Even though the log4j jars may be identical, instances of log4j classes
are not assignable across the different classloaders used for Tomcat's
lib directory and the webapp.

The quick fix is to get rid of the log4j*.jar in your WEB-INF/lib, but
that precludes application-specifc logging.  You could also move
whatever classes from Tomcat's lib directory that the webapp needs into
WEB-INF/lib, rather than having them in the common location.  (This
would be more in keeping with the servlet spec philosophy, which tries
to keep webapps as independent as possible.)  Or, you could rework your
code a bit so the webapp passes a logging object to the methods that
need it that come from Tomcat's lib directory, and insure that the
shared classes don't hang onto that logger.  There may be other

 - Chuck

MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message