commons-httpclient
我在集成测试套件中使用3.1。默认日志记录HttpClient
非常嘈杂,我似乎无法将其关闭。我已经尝试按照此处的说明进行操作,但它们都没有任何区别。
大多数情况下,我只需要让 org.apache.http.wire 记录器闭嘴。部分问题是我不知道HttpClient
正在尝试使用哪种类型的记录器。我以前从未使用过这个库。我尝试创建一个 log4j.properties 文件并将其放在我的 test/resources 文件夹中,修改 jre/lib 中的主 logging.properties 文件,并将各种日志记录选项发送到 Maven,如日志记录页面上指定的那样,但没有一个有所作为。
更新:更正:似乎有问题的输出实际上是通过 jwebunit 使用的HttpClient
,而不是我自己的。无论哪种方式,都是不可取的。
更新:感谢您迄今为止的尝试。我已经尝试了下面建议的所有方法,但仍然没有运气。我的 src/test/resources 文件夹中有一个文件 commons-logging.properties,其中包含以下内容
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jFactory
log4j.configuration=log4j.properties
以及同一文件夹中的文件 log4j.properties,其内容如下
log4j.rootLogger=ERROR, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%c] %m%n
#This is the line that should make httpclient shut up
log4j.logger.org.apache.http=ERROR
但是,当我运行测试时,我仍然会得到一堆这样的输出:
21:57:41.413 [main] DEBUG org.apache.http.wire - << " [\r][\n]"
21:57:41.413 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
21:57:41.413 [main] DEBUG org.apache.http.wire - << " [\r][\n]"
21:57:41.413 [main] DEBUG org.apache.http.wire - << " </ul>[\n]"
21:57:41.413 [main] DEBUG org.apache.http.wire - << " [\n]"
21:57:41.424 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << " </div>[\r][\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << " </li>[\r][\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << " [\r][\n]"
21:57:41.425 [main] DEBUG org.apache.http.wire - << " [\r][\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << " </ul>[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.433 [main] DEBUG org.apache.http.wire - << "<div class="details">[\n]"
21:57:41.442 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "<div class="details-body details-precis ">[\n]
"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "<div class="details-state">[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.443 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "</div>[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\n]"
21:57:41.455 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
Destroying 1 processes21:57:41.465 [main] DEBUG org.apache.http.wire - << "[\r][\n]"
电线上所有东西的输出使这个库对我无法使用……直到我弄清楚如何将其关闭。我需要做些什么才能读取此日志配置吗?