Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ: How to set log levels for tests

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?

like image 432
feob Avatar asked Dec 17 '17 21:12

feob


1 Answers

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.

like image 137
SlawomirR Avatar answered Sep 24 '22 07:09

SlawomirR