当我运行 Spring boot 应用程序时,我会在控制台日志中收到条件评估报告。
如何在 Spring boot 中从控制台日志中禁用或排除此报告?
============================
CONDITIONS EVALUATION REPORT
============================
Positive matches:
-----------------
AopAutoConfiguration matched:
- @ConditionalOnClass found required classes 'org.springframework.context.annotation.EnableAspectJAutoProxy', 'org.aspectj.lang.annotation.Aspect', 'org.aspectj.lang.reflect.Advice', 'org.aspectj.weaver.AnnotatedElement'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)
AopAutoConfiguration.CglibAutoProxyConfiguration matched:
- @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)
CacheAutoConfiguration matched:
- @ConditionalOnClass found required class 'org.springframework.cache.CacheManager'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- @ConditionalOnBean (types: org.springframework.cache.interceptor.CacheAspectSupport; SearchStrategy: all) found bean 'cacheInterceptor'; @ConditionalOnMissingBean (names: cacheResolver; types: org.springframework.cache.CacheManager; SearchStrategy: all) did not find any beans (OnBeanCondition)
...
您可以通过更改
org.springframework.boot.autconfigure
的日志级别来做到这一点。例如,在 application.properties
中添加以下行:
logging.level.org.springframework.boot.autoconfigure=ERROR
如果您满足以下条件,您将获得病情结果报告:
debug=true
。org.springframework.boot.autoconfigure.logging
的日志级别设置为 DEBUG
。当您试图找出为什么某些 bean 没有被加载时,这可能很有用,因为通过此报告,您可以准确地看到哪个自动配置正在加载,哪个没有加载(以及原因)。
您可以通过撤消前面提到的要点来禁用此输出。例如,您可以将
org.springframework.boot.autoconfigure.logging
的日志记录级别设置为 INFO
:
logging.level.org.springframework.boot.autoconfigure.logging=INFO
只需将以下内容添加到 application.yml
logging:
level:
ROOT: INFO
you/package/path: INFO
如果你有 application.yml 答案是
logging:
level:
org.springframework.boot: ERROR
如果您正在使用
运行应用程序java -jar myApp.jar ----debug
然后从命令中删除
--debug
选项