On Jan 19, 2009, at 6:12 PM, Vasiliy Baranov wrote:
> 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.
>
Want to log an issue? we can modify LoggingFilter or most likely
create another logging class that logs to a particular logger.
Paul.