删除 HttpClient "http-outgoing"日志行



我正在使用HttpClient 4.5.2来管理http请求。 默认情况下,它将日志行发送到我的日志文件,格式为:

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

它将日志大小乘以 10 或更多!!

我怎样才能避免这些行。 我的日志是基于log4j的。

这是解决方案: https://hc.apache.org/httpcomponents-client-ga/logging.html

我将 log4j 的行放在我的应用程序主类构造函数中。

如果您使用的是 Log4j 2.x,则将org.apache.http Logger设置为 Info 级别。 这将阻止日志消息,因为这些消息是在Debug级别记录的。

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

最新更新