0

I having a JUnit gradle project that uses the Java AWS s3 client.

compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.707'
compile group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: '1.11.707'

Since adding this client I am getting tons of log message from org.apache.http classes. I cannot figure out how to disable them.

My tests use logback. Here is my config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <root level="error">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
        <appender-ref ref="STDOUT"/>
    </root>


    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <logger name="guru.springframework.controllers" level="WARN" additivity="false">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </logger>
    <logger name="guru.springframework.helpers" level="WARN" additivity="false">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </logger>

    <logger name="com.jayway.jsonpath" level="INFO"/>
    <statusListener class="ch.qos.logback.core.status.NopStatusListener" />

    <logger name="org.apache.zookeeper" level="OFF"/>
    <logger name="org.apache.kafka" level="OFF"/>
    <logger name="ch.qos.logback" level="OFF"/>

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

 </configuration>

There are a variety of posts around that suggest ways to solve this, none of which have worked for me. Here is an example of one:

Turn Off Apache Common Logging

With a Junit test I have no main() and I don't know if there is a similar place to put something like:

 System.setProperty("org.apache.commons.logging.Log",
                         "org.apache.commons.logging.impl.NoOpLog");

Here is another idea that doesn't work for me:

Disable HttpClient logging

Having these lines in my logback config doesn't see to do anything:

    <logger name="org.apache" level="ERROR" />
    <logger name="httpclient" level="ERROR" />
chrismead
  • 2,163
  • 3
  • 24
  • 36

1 Answers1

1

My issue was the fact that I only had a

main/resources/logback-spring.xml

What I needed was a:

test/resources/logback-test.xml

I am assuming that I needed this because one of my dependencies has a logback-test.xml that was being used instead of my main/resources/logback-spring.xml.

chrismead
  • 2,163
  • 3
  • 24
  • 36