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:

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

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

    <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="" level="OFF"/>

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.