I am writing an application in which I am uploading a file using HTTP protocol to a server. Everything is working fine and I am able to upload the file, I have used Apache HTTP client jar set to accomplish this. In the application I have used log4j logging framework which has been set to DEBUG level, by default Apache HTTP Client has also picked up the same logging framework with same logging level and it is producing tons of logs. Can anyone guide me how I can i disable logging of apache Http client?
I am configuring log4j with the help of an XML file name log4j.xml.
By using Commons Logging , HttpClient can be configured for a variety of different logging behaviours. That means the user will have to make a choice which logging framework to use. By default Commons Logging supports the following logging frameworks: Log4J 2.
Wire logging is used to enable debugging request and response messages and attributes. If you need to enable wire logging, you can add package in log4j2.xml.
Http client is a transfer library. It resides on the client side, sends and receives Http messages. It provides up to date, feature-rich, and an efficient implementation which meets the recent Http standards.
Logging levels explained. The most common logging levels include FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL, and OFF. Some of them are important, others less important, while others are meta-considerations.
Assuming you are using httpclient 4, doesn't adding something like this to your log4j.xml work:
<logger name="org.apache.http">
<level value="warn"/>
</logger>
I you don't have a log4j.xml create one and it to your classpath.
If you're using httpclient 3 then you'll have to use something like:
<logger name="org.apache.commons.httpclient">
<level value="warn"/>
</logger>
In these examples I've set the level to warn, you might chose to use none, but a minimum of error would be sensible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With