如何从 Spring boot 应用程序的控制台中排除条件评估报告?

问题描述 投票:0回答:7

当我运行 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)

...
spring spring-boot
7个回答
48
投票

您可以通过更改

org.springframework.boot.autconfigure
的日志级别来做到这一点。例如,在
application.properties
中添加以下行:

logging.level.org.springframework.boot.autoconfigure=ERROR

38
投票

如果您满足以下条件,您将获得病情结果报告:

  • 配置您的 IDE 以显示调试输出(例如,如果您在 IntelliJ 中的 Spring boot 运行配置中设置启用调试输出)。
  • 在 application.properties 中设置属性
    debug=true
  • org.springframework.boot.autoconfigure.logging
    的日志级别设置为
    DEBUG

当您试图找出为什么某些 bean 没有被加载时,这可能很有用,因为通过此报告,您可以准确地看到哪个自动配置正在加载,哪个没有加载(以及原因)。

您可以通过撤消前面提到的要点来禁用此输出。例如,您可以将

org.springframework.boot.autoconfigure.logging
的日志记录级别设置为
INFO

logging.level.org.springframework.boot.autoconfigure.logging=INFO

11
投票

虽然其他答案有效,但也可以将日志级别设置为

INFO

logging.level.org.springframework.boot.autoconfigure=INFO

1
投票

只需将以下内容添加到 application.yml

logging:
  level:
    ROOT: INFO
    you/package/path: INFO

1
投票

还可以在“运行/调试配置”->修改选项->“启用调试输出”中禁用

IntelliJ DebugConfigration


0
投票

如果你有 application.yml 答案是

logging:
  level:
    org.springframework.boot: ERROR

0
投票

如果您正在使用

运行应用程序
java -jar myApp.jar ----debug

然后从命令中删除

--debug
选项

© www.soinside.com 2019 - 2024. All rights reserved.