Disable apache http client logging?

I am writing an application in which I upload a file using the HTTP protocol to a server. Everything works fine, and I can upload the file, I used the Apache HTTP client jar to accomplish this. In the application, I used the log4j framework, which was set to the DEBUG level, by default Apache HTTP Client also took the same logging system with the same logging level and produces tons of logs. Can someone tell me how can I turn off Apache logging of the Http client?

I am configuring log4j using the log4j.xml XML file name.

+5
source share
3 answers

, httpclient 4, - this log4j.xml:

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

log4j.xml, , .

httpclient 3, - :

<logger name="org.apache.commons.httpclient">
  <level value="warn"/> 
</logger>

warn, none, .

+7

, , . , , HTTP- Apache. - :

<logger name="org.apache.commons.httpclient">
  <level value="warn"/> 
</logger>

- , , Apache HTTP. . .

, , :

. , HttpClient org.apache.commons.httpclient.HttpClient. , org.apache.commons.httpclient.

.

, , , . , , , . , :

2013-02-07 15:33:02,369 DEBUG [Some thread name] org.apache.commons.httpclient.Wire.wire(Wire.java:84) - << "[\r]"

, Wire.java, 84. IDE, :

80    if (buffer.length() > 0) {
81        buffer.append("\"");
82        buffer.insert(0, "\"");
83        buffer.insert(0, header);
84        log.debug(buffer.toString()); // Log is happening here
85    }

. , :

52 /** Log for any wire messages. */
53 private Log log;
54 
55 private Wire(Log log) {
56    this.log = log;
57 }

, , 56 . 56, . Log, , "name". "httpclient". Obvioulsly, Apache .

:

<logger name="httpclient">
  <level value="warn"/> 
</logger>

:

  • , .

  • , . - . , . Apache .

  • , . .

+1

. http://wiki.apache.org/logging-log4j/Log4jXmlFormat:

<logger name="com.eatmutton.muttonsite.torque" additivity="false">
   <level value="info" />
   <appender-ref ref="local-torque" />
</logger>

, "debug", com.eatmutton.muttonsite.torque( ) "info", , , HTTP-, ​​ .

0

All Articles