Skip to content
Advertisement

Can’t turn off HttpClient Wire debug log messages

I have been trying to set Wire to not send DEBUG to console, but no matter what I do, it won’t listen.

I have log4j initialized properly: I do not get any appender messages, log4j is obeying my class and console levels.

In log4j.properties I have every foreseeable way to write wire:

    log4j.logger.org.httpclient=ERROR
    log4j.logger.org.apache=ERROR
    log4j.logger.org.apache.http=ERROR
    log4j.logger.org.apache.http.wire=ERROR
    log4j.logger.org.apache.http.wire.headers=ERROR
    log4j.logger.httpclient.wire=ERROR
    log4j.logger.httpclient.headers=ERROR
    log4j.logger.httpclient.content=ERROR
    log4j.logger.org.apache.hc.client5.http.wire=ERROR
    log4j.logger.httpclient=ERROR
    wire=ERROR
    http=ERROR

I then thought why not print all loggers after calling it? So i did just that. I get a nice printout of everything mentioned above, and my current class. Nothing else prints from iterating through LogManager.getCurrentLoggers()

I think I’ve read every result on Google at this point. Any guidance would be appreciated.

About the project: Project is a maven Project – pom.xml includes the resource folder. To make this work I literally made a ControlLogging class and PropertyConfiguratior.configure("log4j.properties") is called first. I call this function @Before test runs, and in the static class that’s making the API calls. Doing the printing at any point doesn’t reveal the Wire logger.

Advertisement

Answer

So what did finally work for my project was creating a configuration for sl4j / logback — I couldn’t make it work for log4j etc.

So under main/java/resources/logback.xml

<xml version="1.0" encoding="UTF-8" ?>
     <configuration>
     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
          <pattern>%d{HH:mm:ss} %thread %-5level %logger{36} %msg%n</pattern>
     </encoder>
     </appender>

     <logger name="org.apache" level="ERROR"/>
     <logger name="httpclient" level="ERROR"/>

     <root level="DEBUG">
          <appender-ref ref="STDOUT" />
     </root>
</configuration>

in maven I simply included dependency for slf4j

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

and its all working now.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement