You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by John Melody <jo...@sybernet.ie> on 2004/05/24 16:07:20 UTC

Wire log to Log4J logger.

Is there a way to configure the wire log to go to a Log4J log configured
for the application.

I have configured Log4J as my application logger and I would like to send
the
Httpclient wire log to the same file. Currently it is set up as the
following -

System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire
", "debug");
which sends the wire log to the console.

Is it possible to configure this so that all the logging output including
the
wire log would go to my log4J application log?

thanks for any help,
regards, John.



John Melody
SyberNet Ltd.
Galway Business Park,
Dangan,
Galway.
Tel. No. +353 91 514400
Fax. NO. +353 91 514409
Mobile - 087-2345847


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


Re: Wire log to Log4J logger.

Posted by Michael Becke <be...@u.washington.edu>.
Hi Eric,

I would suggest posting this question to the commons-logging and tomcat  
folks.  This one is pretty well out of our scope.

Mike

On Jul 11, 2004, at 9:16 PM, Eric Bloch wrote:

> Hey Folks,
>
> I'm having trouble making httpclient 2.0 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 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
>
>
> Michael Becke wrote:
>
>> Hi John,
>> HttpClient uses commons-logging which defaults to Log4j when it is   
>> present on the classpath.  You can enable wire logging by setting the  
>>  logger "httpclient.wire" to DEBUG.  This can be done using any of   
>> Log4j's standard configuration methods.
>> Mike
>> On May 24, 2004, at 10:07 AM, John Melody wrote:
>>>
>>> Is there a way to configure the wire log to go to a Log4J log   
>>> configured
>>> for the application.
>>>
>>> I have configured Log4J as my application logger and I would like to  
>>>  send
>>> the
>>> Httpclient wire log to the same file. Currently it is set up as the
>>> following -
>>>
>>> System.setProperty("org.apache.commons.logging.simplelog.log.httpclie 
>>> nt .wire
>>> ", "debug");
>>> which sends the wire log to the console.
>>>
>>> Is it possible to configure this so that all the logging output   
>>> including
>>> the
>>> wire log would go to my log4J application log?
>>>
>>> thanks for any help,
>>> regards, John.
>>>
>>>
>>>
>>> John Melody
>>> SyberNet Ltd.
>>> Galway Business Park,
>>> Dangan,
>>> Galway.
>>> Tel. No. +353 91 514400
>>> Fax. NO. +353 91 514409
>>> Mobile - 087-2345847
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:   
>>> commons-httpclient-dev-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:   
>>> commons-httpclient-dev-help@jakarta.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:  
>> commons-httpclient-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:  
>> commons-httpclient-dev-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:  
> commons-httpclient-dev-help@jakarta.apache.org
>


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


Re: Wire log to Log4J logger.

Posted by Eric Bloch <bl...@laszlosystems.com>.
Hey Folks,

I'm having trouble making httpclient 2.0 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 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


Michael Becke wrote:

> Hi John,
> 
> HttpClient uses commons-logging which defaults to Log4j when it is  
> present on the classpath.  You can enable wire logging by setting the  
> logger "httpclient.wire" to DEBUG.  This can be done using any of  
> Log4j's standard configuration methods.
> 
> Mike
> 
> On May 24, 2004, at 10:07 AM, John Melody wrote:
> 
>>
>> Is there a way to configure the wire log to go to a Log4J log  configured
>> for the application.
>>
>> I have configured Log4J as my application logger and I would like to  
>> send
>> the
>> Httpclient wire log to the same file. Currently it is set up as the
>> following -
>>
>> System.setProperty("org.apache.commons.logging.simplelog.log.httpclient 
>> .wire
>> ", "debug");
>> which sends the wire log to the console.
>>
>> Is it possible to configure this so that all the logging output  
>> including
>> the
>> wire log would go to my log4J application log?
>>
>> thanks for any help,
>> regards, John.
>>
>>
>>
>> John Melody
>> SyberNet Ltd.
>> Galway Business Park,
>> Dangan,
>> Galway.
>> Tel. No. +353 91 514400
>> Fax. NO. +353 91 514409
>> Mobile - 087-2345847
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:  
>> commons-httpclient-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:  
>> commons-httpclient-dev-help@jakarta.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org

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


Re: Wire log to Log4J logger.

Posted by Michael Becke <be...@u.washington.edu>.
Hi John,

HttpClient uses commons-logging which defaults to Log4j when it is  
present on the classpath.  You can enable wire logging by setting the  
logger "httpclient.wire" to DEBUG.  This can be done using any of  
Log4j's standard configuration methods.

Mike

On May 24, 2004, at 10:07 AM, John Melody wrote:

>
> Is there a way to configure the wire log to go to a Log4J log  
> configured
> for the application.
>
> I have configured Log4J as my application logger and I would like to  
> send
> the
> Httpclient wire log to the same file. Currently it is set up as the
> following -
>
> System.setProperty("org.apache.commons.logging.simplelog.log.httpclient 
> .wire
> ", "debug");
> which sends the wire log to the console.
>
> Is it possible to configure this so that all the logging output  
> including
> the
> wire log would go to my log4J application log?
>
> thanks for any help,
> regards, John.
>
>
>
> John Melody
> SyberNet Ltd.
> Galway Business Park,
> Dangan,
> Galway.
> Tel. No. +353 91 514400
> Fax. NO. +353 91 514409
> Mobile - 087-2345847
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:  
> commons-httpclient-dev-help@jakarta.apache.org
>


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