简体   繁体   English

如何使用 Apache HttpClient 5 启用线路日志记录

[英]How to enable wire logging with Apache HttpClient 5

The Apache HttpClient logging documentation says: Apache HttpClient 日志记录文档说:

The simplest way to configure Log4j 2 is via a log4j2.xml file.配置 Log4j 2 的最简单方法是通过 log4j2.xml 文件。 Log4j 2 will automatically configure itself using a file named log4j2.xml when it's present at the root of the application classpath.当 Log4j2.xml 位于应用程序类路径的根目录时,Log4j 2 将使用名为 log4j2.xml 的文件自动配置自身。

It then gives examples of XML that can be used.然后给出了可以使用的 XML 示例。 None of the examples work, and no debug information is printed.这些示例都不起作用,也没有打印调试信息。

This answer says this can be fixed by adding log4j-core and log4j-1.2-api jars to the classpath. 这个答案说这可以通过将 log4j-core 和 log4j-1.2-api jars 添加到类路径来解决。 I've added log4j-core-2.9.1.jar and log4j-1.2-api-2.9.1.jar and this doesn't fix the problem.我添加了 log4j-core-2.9.1.jar 和 log4j-1.2-api-2.9.1.jar 但这并不能解决问题。 I'm using httpcomponents-client-5.0-beta7 and httpcomponents-core-5.0-beta11.我正在使用 httpcomponents-client-5.0-beta7 和 httpcomponents-core-5.0-beta11。

Exactly which jars do I need to use, and exactly what configuration do I need to do?我到底需要使用哪些 jars,我需要做哪些配置?

Through experimentation, I've made it work by including the following jars:通过实验,我通过包含以下 jars 使其工作:

log4j-api-2.9.1.jar
log4j-core-2.9.1.jar
log4j-slf4j-impl-2.9.1.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM