我有一些麻煩擺脫由彈簧產生調試消息(類同以下的人;有成千上萬的條目):無法禁用日誌消息
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>
<!-- ... -->
我讀的地方,春天似乎使用「通用日誌」在默認情況下,該我不成功嘗試使用禁用(如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的依賴,希望這會覆蓋默認日誌記錄。由於信息格式保持不變,這種嘗試似乎也不成功。
接下來我可以嘗試什麼?
您使用的配置文件呢? – cxdf
@ c-qjv0xfi:不,所有配置都通過註釋完成。添加一個禁用日誌記錄是否必要? – Matthias
我剛剛發現了一個解決方法:http://stackoverflow.com/a/3838108/232175 – Matthias