简体   繁体   中英

How to enable wire logging with Apache HttpClient 5

The Apache HttpClient logging documentation says:

The simplest way to configure Log4j 2 is via a log4j2.xml file. Log4j 2 will automatically configure itself using a file named log4j2.xml when it's present at the root of the application classpath.

It then gives examples of XML that can be used. 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. 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. I'm using httpcomponents-client-5.0-beta7 and httpcomponents-core-5.0-beta11.

Exactly which jars do I need to use, and exactly what configuration do I need to do?

Through experimentation, I've made it work by including the following jars:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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