spring-boot - @SpringBootTest : pre-test logging set to debug by default?

标签 spring-boot logging

一个简单的 spring-boot 项目 ( Initializr link ) 会生成一个 @SpringBootTest 类,该类会发出以下 DEBUG 日志消息:

DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - ...
DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - ... 
DEBUG org.springframework.test.context.BootstrapUtils - ... 
DEBUG org.springframework.test.context.support.AbstractContextLoader - ...
DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - ...
DEBUG org.springframework.test.context.support.ActiveProfilesUtils - ...
DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - ...
DEBUG org.springframework.test.context.support.TestPropertySourceUtils - ...

这发生在实际测试类开始执行之前。

  1. 启用该日志记录的配置在哪里?
  2. 此功能的文档记录在哪里?
  3. 如何关闭它?

谢谢!

最佳答案

除了信息@simon-martinelli提供,这个Baeldung article也可能有帮助。

总之:您可以将 logback-test.xml 添加到测试类路径的根目录中,以配置日志级别以避免 DEBUG 日志或完全禁用日志记录。 :)

关于spring-boot - @SpringBootTest : pre-test logging set to debug by default?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68272076/

相关文章:

c# - 使用 Serilog 时如何覆盖 appsettings.json 中指定的应用程序名称?

java - 忽略子线程生成的日志

java - Spring boot 删除不是级联,而是将外键设置为 null,然后在 null 约束上失败

java - 在 Spring-boot 中为特定的异步请求设置超时

spring - log4j2 中 xwEx 的含义?

java - 处理多部分/表单数据请求时,Spring Boot 1.3.7 中的文件始终为空

Python解析日志文件实时提取事件

java - 使用 Spring WebClient 发出多个请求

python - 无论级别设置如何,如何始终将日志消息写入文件

java - 如何收集不同节点的访问日志?