一个简单的 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 - ...
这发生在实际测试类开始执行之前。
- 启用该日志记录的配置在哪里?
- 此功能的文档记录在哪里?
- 如何关闭它?
谢谢!
最佳答案
除了信息@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/