Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable logging of apache HTTP Client?

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.

like image 605
user381878 Avatar asked Mar 02 '11 10:03

user381878


People also ask

Does Apache HttpClient use Log4J?

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.

What is wire logging Log4J?

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.

What is Apache HttpClient used for?

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.

What are the log levels?

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.


1 Answers

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.

like image 113
Joel Avatar answered Sep 20 '22 02:09

Joel