Skip to content

Recommended logback configuration

Testcontainers, and many of the libraries it uses, utilize SLF4J for logging. In order to see logs from Testcontainers, your project should include an SLF4J implementation (Logback is recommended). The following example logback-test.xml should be included in your classpath to show a reasonable level of log output:

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="STDOUT"/>
    </root>

    <logger name="org.testcontainers" level="INFO"/>
    <!-- The following logger can be used for containers logs since 1.18.0 -->
    <logger name="tc" level="INFO"/>
    <logger name="com.github.dockerjava" level="WARN"/>
    <logger name="com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire" level="OFF"/>
</configuration>

In order to troubleshoot issues with Testcontainers, increase the logging level of org.testcontainers to DEBUG:

<logger name="org.testcontainers" level="DEBUG"/>

Avoid changing the root logger's level to DEBUG, because this turns on debug logging for every package whose level isn't explicitly configured here, resulting in a large amount of log data.