spring-boot - IntelliJ : How to set log levels for tests

标签 spring-boot logging intellij-idea junit log-level

我在IntelliJ 2016中测试控制台输出有问题。
当我通过IntelliJ运行JUnit测试时,控制台窗口充满了大量的日志行,例如

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

这是一个使用默认日志记录的简单Spring-Boot应用程序-我认为它是slf4j。
我尝试设置
logging.level.reactor.ipc=WARN

在我的src/main/resources/application.properties中,同时设置

RunConfig的VM参数上的-Dlogging.level.root=WARN,但对日志输出都没有任何影响。
从Intellij执行测试时,配置日志记录详细程度的正确位置是什么?

最佳答案

您可以使用以下示例内容填充src/test/resources中名为logback.xml的文件:

<?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>

具有TRACE日志记录级别。您可以更改此日志级别以满足您的需求。

关于spring-boot - IntelliJ : How to set log levels for tests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47859462/

相关文章:

java - Intellij Idea中的JUnit生成空测试类体

java - 字符串索引超出范围 : 0 Error For using RedirectAttributes in Spring Boot

java - 环境变量中的数据库凭据?

node.js - 调用堆栈的深度

tomcat - com.google.inject.CreationException : Unable to create injector, 看到如下错误

intellij-idea - 运行特定运行配置的宏

java - Spring Sleuth - JMS ErrorHandler 上的跟踪中断

java - 为什么spring-boot连接不上本地mysql服务器?

java - 在哪里检查日志为什么 VM 不运行带有自定义 jar 的 jconsole?

php - 无法使用带有 curlopt_stderr 和 curlopt_file 的 PHP cURL 写入文件