IntelliJ: How to set log levels for tests

feob picture feob · Dec 17, 2017 · Viewed 8.8k times · Source

I have a problem with test console output in IntelliJ 2016. When I run JUnit tests via IntelliJ, the console window is flooded with enormous amounts of log lines, for example

DEBUG reactor.ipc ....
DEBUG io.netty.buffer.ByteBufUtil ....

It's a simple Spring-Boot application which uses the default logging - I think it's slf4j. I tried setting

logging.level.reactor.ipc=WARN

in my src/main/resources/application.properties and also setting

-Dlogging.level.root=WARN on the RunConfig's VM arguments, but neither has any effect on the log output. What is the correct place to configure logging verbosity when executing Tests from Intellij?

Answer

SlawomirR picture SlawomirR · Apr 19, 2018

You can fill up file named logback.xml in src/test/resources with sample content like:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d %5p | %t | %-55logger{55} | %m %n</pattern>
        </encoder>
    </appender>
    <root>
        <level value="TRACE"/>
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>

to have TRACE logging level. You can change this log level to meet your needs.