You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Eugeny N Dzhurinsky <bo...@redwerk.com> on 2006/06/29 16:39:16 UTC

logging

Hi, I'm using Log4J in my application.
I added
log4j.logger.httpclient.wire.header=DEBUG
log4j.logger.org.apache.commons.httpclient=DEBUG

to log4j.properties file, but I still can't see HTTP headers.
Any ideas why is that?
Here is my log4j.properties.file below:

log4j.rootLogger=DEBUG, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d{dd/mm/yy hh:mm:ss} [%t] (%C{1}:%L) - %m%n
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=monitor.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=3
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p %d{dd/mm/yy hh:mm:ss} [%t] (%C{1}:%L) - %m%n
log4j.logger.org.pdfbox=ERROR
log4j.logger.httpclient.wire.header=DEBUG
log4j.logger.org.apache.commons.httpclient=DEBUG
-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Tue, Jul 04, 2006 at 06:59:18PM +0200, Roland Weber wrote:
> Hello Eugeny,
> 
> > Does it means I need to set up properties for commons loggingtogether with
> > log4j?!
> > Looks weird since on commons logging page stated log4j could be used as well
> > w/o additional configuration for commons-logging.
> 
> If you want to be on the safe side, set up properties that specify which
> logging package you want to use. Commons logging has a default search
> strategy, but that's the part of commons logging where most of the problems
> come from. For example, depending on your JDK version, the default strategy
> may select JDK logging instead of log4j. It's really not so much work to
> write a commons-logging.properties file with a property that specifies the
> log4j factory.

Okay, It seems I solved the problem with commons-logging by providing
commons-logging.properties file with

org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger

Thank you for help!
-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by Roland Weber <ht...@dubioso.net>.
Hello Eugeny,

> Does it means I need to set up properties for commons loggingtogether with
> log4j?!
> Looks weird since on commons logging page stated log4j could be used as well
> w/o additional configuration for commons-logging.

If you want to be on the safe side, set up properties that specify which
logging package you want to use. Commons logging has a default search
strategy, but that's the part of commons logging where most of the problems
come from. For example, depending on your JDK version, the default strategy
may select JDK logging instead of log4j. It's really not so much work to
write a commons-logging.properties file with a property that specifies the
log4j factory.

cheers,
  Roland


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


Re: logging

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Tue, Jul 04, 2006 at 11:28:11PM +1000, Paul King wrote:
> 
> I just tried a simple test (using SimpleLog) that worked for me as follows:
> 
> Created a commons-logging.properties in the classpath containing the 
> following line:
> 
> org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog
> 
> Set classpath to:
> 
> CLASSPATH=classes;lib\commons-httpclient-3.0.1.jar;lib\commons-logging-1.0.3.jar;lib\commons-codec-1.2.jar
> 
> Invoked:
> 
> >java 
> >-Dorg.apache.commons.logging.simplelog.log.httpclient.wire.header=debug 
> >GetPage http://www.google.com
> 
> output:
> [DEBUG] header - ->> "GET / HTTP/1.1[\r][\n]"
> [DEBUG] header - ->> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
> [DEBUG] header - ->> "Host: www.google.com[\r][\n]"
> [DEBUG] header - ->> "[\r][\n]"
> <...DELETED...>
> [DEBUG] header - -<< "Date: Tue, 04 Jul 2006 13:20:18 GMT[\r][\n]"
> Response status code: 200
> Response body:
> <...DELETED...>

Does it means I need to set up properties for commons loggingtogether with
log4j?!
Looks weird since on commons logging page stated log4j could be used as well
w/o additional configuration for commons-logging.

-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by Paul King <pa...@asert.com.au>.
I just tried a simple test (using SimpleLog) that worked for me as follows:

Created a commons-logging.properties in the classpath containing the following line:

org.apache.commons.logging.Log = org.apache.commons.logging.impl.SimpleLog

Set classpath to:

CLASSPATH=classes;lib\commons-httpclient-3.0.1.jar;lib\commons-logging-1.0.3.jar;lib\commons-codec-1.2.jar

Invoked:

> java -Dorg.apache.commons.logging.simplelog.log.httpclient.wire.header=debug GetPage http://www.google.com

output:
[DEBUG] header - ->> "GET / HTTP/1.1[\r][\n]"
[DEBUG] header - ->> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]"
[DEBUG] header - ->> "Host: www.google.com[\r][\n]"
[DEBUG] header - ->> "[\r][\n]"
<...DELETED...>
[DEBUG] header - -<< "Date: Tue, 04 Jul 2006 13:20:18 GMT[\r][\n]"
Response status code: 200
Response body:
<...DELETED...>

Eugeny N Dzhurinsky wrote:
> On Tue, Jul 04, 2006 at 06:34:57PM +1000, Paul King wrote:
>> We use (note the extra httpclient.wire.header):
>>
>> log4j.logger.org.apache.commons.httpclient=info
>> log4j.logger.httpclient.wire=info
>> log4j.logger.httpclient.wire.header=debug
>> log4j.logger.httpclient.wire.content=debug
>>
>> but we also have problems with some configurations getting the
>> information we want.
> 
> This doesn't work for me :(
> 


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


Re: logging

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Tue, Jul 04, 2006 at 06:34:57PM +1000, Paul King wrote:
> 
> We use (note the extra httpclient.wire.header):
> 
> log4j.logger.org.apache.commons.httpclient=info
> log4j.logger.httpclient.wire=info
> log4j.logger.httpclient.wire.header=debug
> log4j.logger.httpclient.wire.content=debug
> 
> but we also have problems with some configurations getting the
> information we want.

This doesn't work for me :(

-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by Paul King <pa...@asert.com.au>.
We use (note the extra httpclient.wire.header):

log4j.logger.org.apache.commons.httpclient=info
log4j.logger.httpclient.wire=info
log4j.logger.httpclient.wire.header=debug
log4j.logger.httpclient.wire.content=debug

but we also have problems with some configurations getting the
information we want.

Cheers, Paul.

Eugeny N Dzhurinsky wrote:
> On Sat, Jul 01, 2006 at 01:26:40PM +0800, neil al wrote:
>> here is my log4j.xml
> 
> I modified it a bit:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
>     <appender name="appender" class="org.apache.log4j.ConsoleAppender">
>         <param name="Threshold" value="DEBUG" />
> 
>         <layout class="org.apache.log4j.PatternLayout">
>             <param name="ConversionPattern" value="%d{HH:mm:ss} [%t] %p (%c) - %m%n" />
>         </layout>
>     </appender>
> 
>     <category name="httpclient.wire.content">
>         <priority value="INFO" />
>     </category>
> 
>     <category name="org.apache.commons.httpclient.HttpParser">
>         <priority value="INFO" />
>     </category>
> 
>     <root>
>         <priority value="debug" />
>         <appender-ref ref="appender" />
>     </root>
> </log4j:configuration>
> 
> 
>> Is your log4j.xml is in the classpath?
> 
> yes, it is
> 
> But still no luck - I can see debug output from my application, but I can't
> see any output about HTTP headers etc.
> 


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


Re: logging

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Sat, Jul 01, 2006 at 01:26:40PM +0800, neil al wrote:
> here is my log4j.xml

I modified it a bit:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="appender" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="DEBUG" />

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss} [%t] %p (%c) - %m%n" />
        </layout>
    </appender>

    <category name="httpclient.wire.content">
        <priority value="INFO" />
    </category>

    <category name="org.apache.commons.httpclient.HttpParser">
        <priority value="INFO" />
    </category>

    <root>
        <priority value="debug" />
        <appender-ref ref="appender" />
    </root>
</log4j:configuration>


> Is your log4j.xml is in the classpath?

yes, it is

But still no luck - I can see debug output from my application, but I can't
see any output about HTTP headers etc.

-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by neil al <nv...@gmail.com>.
here is my log4j.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="appender" class="
org.apache.log4j.DailyRollingFileAppender">
        <param name="Threshold" value="DEBUG"/>
        <param name="File" value="log/message.log"/>
        <param name="Append" value="true"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{MMMM dd, yyyy
HH:mm:ss} [%t] %p (%c) - %m%n"/>
        </layout>
    </appender>

    <appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender
">

        <param name="Threshold" value="DEBUG"/>

        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss} [%t] %p (%c)
- %m%n"/>
        </layout>
    </appender>

    <category name="httpclient.wire.content">
        <priority value="INFO"/>
    </category>

    <category name="org.apache.commons.httpclient.HttpParser">
        <priority value="INFO"/>
    </category>

    <root>
        <priority value ="debug" />
        <appender-ref ref="consoleAppender"/>
        <appender-ref ref="appender"/>
    </root>
</log4j:configuration>

Is your log4j.xml is in the classpath?

On 6/30/06, Eugeny N Dzhurinsky <bo...@redwerk.com> wrote:
>
> On Fri, Jun 30, 2006 at 09:34:28AM +0800, neil al wrote:
> > Hi,
> >
> > I am not sure about this :
> >     log4.categroy.httpclient.wire.header = DEBUG
> >
> > this works on the log4j.xml and the statement is
> >
> > <category name="httpclient.wire.header" >   <priority value="DEBUG" />
> > </category>
>
> I added
> log4j.category.httpclient.wire=DEBUG
> to log4j.properties, but still no luck. May be any other ideas? Or you
> could
> probably provide example of XML file which works for you, so I could try
> it?
>
> --
> Eugene N Dzhurinsky
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

Re: logging

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Fri, Jun 30, 2006 at 09:34:28AM +0800, neil al wrote:
> Hi,
> 
> I am not sure about this :
>     log4.categroy.httpclient.wire.header = DEBUG
> 
> this works on the log4j.xml and the statement is
> 
> <category name="httpclient.wire.header" >   <priority value="DEBUG" />
> </category>

I added 
log4j.category.httpclient.wire=DEBUG
to log4j.properties, but still no luck. May be any other ideas? Or you could
probably provide example of XML file which works for you, so I could try it?

-- 
Eugene N Dzhurinsky

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


Re: logging

Posted by neil al <nv...@gmail.com>.
Hi,

I am not sure about this :
     log4.categroy.httpclient.wire.header = DEBUG

this works on the log4j.xml and the statement is

<category name="httpclient.wire.header" >   <priority value="DEBUG" />
</category>

On 6/29/06, Eugeny N Dzhurinsky <bo...@redwerk.com> wrote:
>
> Hi, I'm using Log4J in my application.
> I added
> log4j.logger.httpclient.wire.header=DEBUG
> log4j.logger.org.apache.commons.httpclient=DEBUG
>
> to log4j.properties file, but I still can't see HTTP headers.
> Any ideas why is that?
> Here is my log4j.properties.file below:
>
> log4j.rootLogger=DEBUG, stdout, file
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%5p %d{dd/mm/yy hh:mm:ss}
> [%t] (%C{1}:%L) - %m%n
> log4j.appender.file=org.apache.log4j.RollingFileAppender
> log4j.appender.file.File=monitor.log
> log4j.appender.file.MaxFileSize=10MB
> log4j.appender.file.MaxBackupIndex=3
> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%5p %d{dd/mm/yy hh:mm:ss}
> [%t] (%C{1}:%L) - %m%n
> log4j.logger.org.pdfbox=ERROR
> log4j.logger.httpclient.wire.header=DEBUG
> log4j.logger.org.apache.commons.httpclient=DEBUG
> --
> Eugene N Dzhurinsky
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>