【问题标题】:Removing HttpClient "http-outgoing" log lines删除 HttpClient“http-outgoing”日志行
【发布时间】:2017-04-04 08:45:13
【问题描述】:

我正在使用 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 的。

【问题讨论】:

    标签: java logging apache-httpclient-4.x apache-httpcomponents


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-11-12
        • 1970-01-01
        • 1970-01-01
        • 2017-01-02
        • 1970-01-01
        • 1970-01-01
        • 2017-09-28
        相关资源
        最近更新 更多