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 JOSE L MARTINEZ-AVIAL <jl...@gmail.com> on 2013/06/13 13:26:06 UTC

Logging of httpclient.wire.content depending on the target of the connection

Hi,
   I have an web application that uses Axis2 1.6.2 to connect to diferent
webservices. The underlying protocol is HTTP, so it uses httpcore-4.0 to
connect to the server. My problem is that for auditory reasons I need to
log the requests and responses received from a particular webservice, but
the other webservices should not be logged. I know I can setup
httpclient.wire.content to DEBUG in order to log the content of the
request/responses, but how I can do that dynamically depending on the
server the request is going to?

  Thanks

JL

Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2013-06-13 at 07:26 -0400, JOSE L MARTINEZ-AVIAL wrote:
> Hi,
>    I have an web application that uses Axis2 1.6.2 to connect to diferent
> webservices. The underlying protocol is HTTP, so it uses httpcore-4.0 to
> connect to the server. My problem is that for auditory reasons I need to
> log the requests and responses received from a particular webservice, but
> the other webservices should not be logged. I know I can setup
> httpclient.wire.content to DEBUG in order to log the content of the
> request/responses, but how I can do that dynamically depending on the
> server the request is going to?
> 
>   Thanks
> 
> JL

You'll have to develop a custom connection implementation and / or a
custom connection manager.

Oleg


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


Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Actually, the change should be implemented in
ManagedHttpClientConnectionFactory, so the creation of the loggers can be
overwritten.I just created a ticket
https://issues.apache.org/jira/browse/HTTPCLIENT-1374, and uploaded a patch
for the issue.

Thanks
JL


2013/6/14 JOSE L MARTINEZ-AVIAL <jl...@gmail.com>

> Thanks Oleg. Yesterday I didn't have access to a more recent version of
> the source code. I'm now checking the code from the trunk, and see what can
> be done.
>
>
> 2013/6/14 Oleg Kalnichevski <ol...@apache.org>
>
>> On Fri, 2013-06-14 at 01:18 -0400, JOSE L MARTINEZ-AVIAL wrote:
>> > I just took a quick look at the source code(4.3-alpha1), and it seems
>> the
>> > best option would be to modify
>> > org.apache.http.impl.conn.SocketClientConnectionImpl so the wire
>> created in
>> > the constructor would be provided by a protected method. That way the
>> > creation of the wire logger could be customized by extending
>> > SocketClientConnectionImpl.
>> > How does it sound?
>> >
>>
>> Jose
>>
>> You should be using ManagedHttpClientConnectionImpl (or a local copy of
>> it) from 4.3-beta2. 4.3-alpha1 API is helplessly outdated.
>>
>> Hope this helps
>>
>> Oleg
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>

Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
Thanks Oleg. Yesterday I didn't have access to a more recent version of the
source code. I'm now checking the code from the trunk, and see what can be
done.


2013/6/14 Oleg Kalnichevski <ol...@apache.org>

> On Fri, 2013-06-14 at 01:18 -0400, JOSE L MARTINEZ-AVIAL wrote:
> > I just took a quick look at the source code(4.3-alpha1), and it seems the
> > best option would be to modify
> > org.apache.http.impl.conn.SocketClientConnectionImpl so the wire created
> in
> > the constructor would be provided by a protected method. That way the
> > creation of the wire logger could be customized by extending
> > SocketClientConnectionImpl.
> > How does it sound?
> >
>
> Jose
>
> You should be using ManagedHttpClientConnectionImpl (or a local copy of
> it) from 4.3-beta2. 4.3-alpha1 API is helplessly outdated.
>
> Hope this helps
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2013-06-14 at 01:18 -0400, JOSE L MARTINEZ-AVIAL wrote:
> I just took a quick look at the source code(4.3-alpha1), and it seems the
> best option would be to modify
> org.apache.http.impl.conn.SocketClientConnectionImpl so the wire created in
> the constructor would be provided by a protected method. That way the
> creation of the wire logger could be customized by extending
> SocketClientConnectionImpl.
> How does it sound?
> 

Jose

You should be using ManagedHttpClientConnectionImpl (or a local copy of
it) from 4.3-beta2. 4.3-alpha1 API is helplessly outdated.

Hope this helps

Oleg



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


Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by JOSE L MARTINEZ-AVIAL <jl...@gmail.com>.
I just took a quick look at the source code(4.3-alpha1), and it seems the
best option would be to modify
org.apache.http.impl.conn.SocketClientConnectionImpl so the wire created in
the constructor would be provided by a protected method. That way the
creation of the wire logger could be customized by extending
SocketClientConnectionImpl.
How does it sound?
















2013/6/13 Gary Gregory <ga...@gmail.com>

> It would be nice if the host was appended to the logger name, like:
>
> org.apache.http.SomeLogger.127.0.0.1
> org.apache.http.SomeLogger.localhost
> org.apache.http.SomeLogger.com.domain.myapp
>
> This would let you use the dots in IP addresses and domain names as
> hierarchical separators the same way they are used in Log4j.
>
> Gary
>
>
>
> On Thu, Jun 13, 2013 at 7:26 AM, JOSE L MARTINEZ-AVIAL <jlmagc@gmail.com
> >wrote:
>
> > Hi,
> >    I have an web application that uses Axis2 1.6.2 to connect to diferent
> > webservices. The underlying protocol is HTTP, so it uses httpcore-4.0 to
> > connect to the server. My problem is that for auditory reasons I need to
> > log the requests and responses received from a particular webservice, but
> > the other webservices should not be logged. I know I can setup
> > httpclient.wire.content to DEBUG in order to log the content of the
> > request/responses, but how I can do that dynamically depending on the
> > server the request is going to?
> >
> >   Thanks
> >
> > JL
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition<
> http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Logging of httpclient.wire.content depending on the target of the connection

Posted by Gary Gregory <ga...@gmail.com>.
It would be nice if the host was appended to the logger name, like:

org.apache.http.SomeLogger.127.0.0.1
org.apache.http.SomeLogger.localhost
org.apache.http.SomeLogger.com.domain.myapp

This would let you use the dots in IP addresses and domain names as
hierarchical separators the same way they are used in Log4j.

Gary



On Thu, Jun 13, 2013 at 7:26 AM, JOSE L MARTINEZ-AVIAL <jl...@gmail.com>wrote:

> Hi,
>    I have an web application that uses Axis2 1.6.2 to connect to diferent
> webservices. The underlying protocol is HTTP, so it uses httpcore-4.0 to
> connect to the server. My problem is that for auditory reasons I need to
> log the requests and responses received from a particular webservice, but
> the other webservices should not be logged. I know I can setup
> httpclient.wire.content to DEBUG in order to log the content of the
> request/responses, but how I can do that dynamically depending on the
> server the request is going to?
>
>   Thanks
>
> JL
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory