【发布时间】:2015-05-21 07:41:04
【问题描述】:
我正在使用 Selenium 使用 TestNG 框架自动化测试用例。它调用内部使用 HTTPClient 库的 WebDriver。在我的类路径中有多个日志记录 jar,即 - slf4j 和 log4j。
我已经尝试了这里写的几乎所有东西 - Disable HttpClient logging 比如创建一个log4j.properties文件,commons-logging.properties文件然后添加到classpath-src/java/main
所以我有 2 个问题 -
- 如何强制 HttpClient 使用特定的日志记录 jar(因为我没有添加任何有关日志记录 jar 的日志记录依赖项。它们会自动下载,因为其他一些依赖项可能在内部使用它。)
-
如何禁用 HttpClient 的不需要的调试消息。
SLF4J:类路径包含多个 SLF4J 绑定。 SLF4J:在 [jar:file:/C:/Users/~/.m2/repository/ch/qos/logback/logback-classic/1.0.7/logback-classic-1.0.7.jar!/org/ 中找到绑定slf4j/impl/StaticLoggerBinder.class] SLF4J:在 [jar:file:/C:/Users/~/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/ 中找到绑定impl/StaticLoggerBinder.class] SLF4J:在 [jar:file:/C:/Users/~/.m2/repository/org/apache/activemq/activemq-all/5.6.0/activemq-all-5.6.0.jar!/org/ 中找到绑定slf4j/impl/StaticLoggerBinder.class] SLF4J:请参阅http://www.slf4j.org/codes.html#multiple_bindings 以获得解释。 SLF4J:实际绑定的类型为 [ch.qos.logback.classic.util.ContextSelectorStaticBinder] 在端口 3052 上启动 ChromeDriver (v2.9.248315)
18:27:00.726 [Forwarding newSession on session null to remote] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match 18:27:00.727 [Forwarding newSession on session null to remote] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context 18:27:00.727 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://localhost:3052][total kept alive: 0; route allocated: 0 of 2000; total allocated: 0 of 2000] 18:27:00.758 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://localhost:3052][total kept alive: 0; route allocated: 1 of 2000; total allocated: 1 of 2000] 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://localhost:3052 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.HttpClientConnectionOperator - Connecting to localhost/127.0.0.1:3052 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.c.HttpClientConnectionOperator - Connection established 127.0.0.1:50744<->127.0.0.1:3052 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /session HTTP/1.1 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /session HTTP/1.1 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/json; charset=utf-8 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 169 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: localhost:3052 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5) 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /session HTTP/1.1[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/json; charset=utf-8[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 169[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: localhost:3052[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]" 18:27:00.774 [Forwarding newSession on session null to remote] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
【问题讨论】:
标签: logging apache-httpclient-4.x java.util.logging apache-commons-logging