我在摆脱 Spring 生成的调试消息时遇到了一些麻烦(类似于以下消息;有数千个这样的条目):
19:58:08.380 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'propertyPlaceholderConfigurer'
19:58:08.380 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'propertyPlaceholderConfigurer'
19:58:08.383 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'appConfig'
19:58:08.383 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'appConfig'
19:58:08.383 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Eagerly caching bean 'appConfig' to allow for resolving potential circular references
19:58:08.384 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Finished creating instance of bean 'appConfig'
在相关问题中,有很多建议涉及log4j,web.xml,......
但是,我没有使用其中任何一个 - 我只是实例化一个AnnotationConfigApplicationContext
并开始创建bean。
在我的 pom.xml 文件中,没有对任何日志记录框架的引用 - 我只包含 spring 依赖项:
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- ... -->
<artifactId>spring-tx</artifactId>
<!-- ... -->
<artifactId>spring-boot-starter</artifactId>
<!-- ... -->
<artifactId>spring-web</artifactId>
<!-- ... -->
我在某处读到 Spring 似乎默认使用“Commons 日志记录”,但我尝试禁用它但没有成功(如关闭 Apache 通用日志记录 https://stackoverflow.com/questions/1436761/turn-off-apache-common-logging ):
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
此外,我尝试通过添加以下内容来排除 pom.xml 中的公共日志记录:
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
然而,仍然没有运气。
接下来,我尝试包含对 log4j 的依赖项,希望这会覆盖默认日志记录。由于消息的格式保持不变,看来这次尝试也没有成功。
接下来我可以尝试什么?