dushkin
dushkin

Reputation: 2111

Removing HttpClient "http-outgoing" log lines

I am using HttpClient 4.5.2 to manage http requests. By default it sends log lines to my log file in the format of:

http-outgoing-50 >> "0[\r][\n]"
http-outgoing-50 >> "[\r][\n]"
http-outgoing-50 << "HTTP/1.1 200 OK[\r][\n]"
http-outgoing-50 << "Server: Apache-Coyote/1.1[\r][\n]"
http-outgoing-50 << "Content-Type: text/xml[\r][\n]"
http-outgoing-50 << "Content-Length: 163[\r][\n]"
http-outgoing-50 << "Date: Tue, 04 Apr 2017 08:36:40 GMT[\r][\n]"
http-outgoing-50 << "[\r][\n]"
http-outgoing-50 << "<?xml version="1.0" encoding="UTF-8" standalone="yes"?><WbxTSPSchema 
http-outgoing-50 << HTTP/1.1 200 OK
http-outgoing-50 << Server: Apache-Coyote/1.1
http-outgoing-50 << Content-Type: text/xml
http-outgoing-50 << Content-Length: 163
http-outgoing-50 << Date: Tue, 04 Apr 2017 08:36:40 GMT
Connection can be kept alive indefinitely
Response Code : 200
Connection [id: 50][route: {}->http://stires-web-a.smst290.att.com:3100] can be kept alive

It multiples the log size by 10 or more!!!

How can I avoid those lines. My log is log4j based.

Upvotes: 3

Views: 6123

Answers (2)

Nathan
Nathan

Reputation: 8971

If you are using Log4j 2.x, then set the org.apache.http Logger to the Info level. This will block the log messages since those are logged at the Debug level.

<Logger name="org.apache.http" level="Info"/>

Upvotes: 2

dushkin
dushkin

Reputation: 2111

Here is the solution: https://hc.apache.org/httpcomponents-client-ga/logging.html

I put the lines for log4j in my app main class constructor.

Upvotes: 2

Related Questions