You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/07/12 16:51:32 UTC

DO NOT REPLY [Bug 30054] New: - can't get log4j logger in webapp under tomcat5+java1.4

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30054>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30054

can't get log4j logger in webapp under tomcat5+java1.4

           Summary: can't get log4j logger in webapp under tomcat5+java1.4
           Product: Commons
           Version: 1.0.3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Logging
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: bloch@laszlosystems.com


Couldn't find a commons-logging specific email list and thought I'd file
a bug in the hopes that someone might have already seen this.

I'm having trouble making httpclient 2.0 (a user of commons logging)
use log4j logging inside Tomcat5 (when running against java 1.4).  Seems as
though tomcat5 makes some call to the the commons logger early on (see below). 
Tomcat5 doesn't come with log4j... so the commons logging default log factory
implementation picks up the jdk14 logger for tomcat as you'd expect.

I'm guessing that somehow when my webapp comes up... the commons logger fails to
look for log4j in my WEB-INF/lib (this is where it finds httpclient).  

This feels like one of the class-loader disagreements that I've seen related to
java/commons-logging and the servlet spec.  That is, my webapp is getting
tomcat's copy of the default log factor impl, instead of its own.

Fwiw, this is a stack from early tomcat initialization:

LogFactoryImpl.getLogClassName() line: 331
LogFactoryImpl.getLogConstructor() line: 368
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
JdkCompat.<clinit>() line: 53
StandardClassLoader.<clinit>() line: 207
ClassLoaderFactory.createClassLoader(File[], File[], URL[], ClassLoader) line: 189
Bootstrap.createClassLoader(String, ClassLoader) line: 160
Bootstrap.initClassLoaders() line: 104
Bootstrap.init() line: 193
Bootstrap.main(String[]) line: 399

And this is a stack where my initial use of the httpclient ends up picking up
the JDK14 logger even though my webapp has log4j in it's WEB-INF/lib:

Jdk14Logger.<init>(String) line: 50
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not
available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor.newInstance(Object[]) line: 274
LogFactoryImpl.newInstance(String) line: 529
LogFactoryImpl.getInstance(String) line: 235
LogFactoryImpl.getInstance(Class) line: 209
LogFactory.getLog(Class) line: 351
MultiThreadedHttpConnectionManager.<clinit>() line: 98
..
..
..


It isn't an option for me to put touch any of the jars inside the container. 
And I'd like to force httpclient to use log4j when it's used within my webapp. 
This was working fine, fyi, in tomcat4.

Any clues/advice?

Thanks!

-Eric

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org