Turning on Logging in HttpClient

I faced same problem today. And I found out a solution for this problem. It’s pretty simple.
Just add jcl-over-slf4j dependency to forward JCL logging (Apache Commons Logging) to slf4j.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.5</version>
</dependency>

After that you can config log file as Log4j Examples.
If you use logback you can put the following to your logback.xml

<logger name="org.apache.http" level="DEBUG"/>

Or if you use log4j

log4j.logger.org.apache.http=DEBUG

Leave a Comment