users@jersey.java.net

Re: [Jersey] log HTTP exchanges

From: Vasiliy Baranov <Vasiliy.Baranov_at_Sun.COM>
Date: Mon, 19 Jan 2009 20:12:48 +0300

Paul Sandoz wrote:
>
> On Jan 19, 2009, at 5:53 PM, Vasiliy Baranov wrote:
>
>> Hi,
>>
>> With Jersey, is it possible to fully log (e.g. via java.util.logging)
>> all HTTP requests and responses taking place? Like what you get with
>> commons-httpclient when you say:
>>
>>
>> -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
>> \
>> -Dorg.apache.commons.logging.simplelog.showdatetime=true \
>> -Dorg.apache.commons.logging.simplelog.log.httpclient.wire=debug
>>
>> I can see sun.net.www.protocol.http.HttpURLConnection logging message
>> headers, but that is not enough in my case.
>>
>
> Do you want to log on the client side or the server side?
>
> I will presuming it is the client side. You can add the following
> LoggingFilter [1] to the Client.
>
> Client c = ...
> c.addFilter(new LoggingFilter());
>
> If you want to be particular you can add a LoggingFilter instance to a
> WebResource instead.

Oh, I see. (Yes, I want logging on the client side.)

>
> It does not use JDK logging thought, by default it prints out to the
> System.out but you can pass in a PrintStream instance on construction.
> Perhaps it should be changed to utilize logging?

Well, as a data point, I have a semi-third-party library that completely
encapsulates the Client and other Jersey interfaces, so now it looks
like I have to hack it, which would not be necessary if there was an
option to configure HTTP logging in JUL or log4j way.

Thank you,
Vasiliy

>
> Paul.
>
> [1]
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/api/jersey/com/sun/jersey/api/client/filter/LoggingFilter.html
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>