无法通过 com.springframework.context 的 Spring 应用程序配置关闭日志记录

时间:2021-01-18 08:15:33

标签: spring spring-profiles spring-logback spring-properties

我想减少我使用的特定配置文件 local 的日志记录。

我发现要设置这些属性:

logging:
  level:
    org:
      springframework:
        web: ERROR
        context: ERROR

我使用 local 配置文件启动我的应用程序。 运行时,我希望以下语句消失:

2021-01-18 09:08:51,826 INFO  [main] org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-18 09:08:51,829 INFO  [main] org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker: Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.support.PluginRegistryFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

但是它们仍在渲染中。我设置为 debug 的其他日志级别成功呈现 DEBUG 语句。但在这种情况下,我希望语句消失它不起作用。

详情

这是我的完整 application.yaml 文件:

spring:
  profiles:
    active: cloud
  datasource:
    url: jdbc:mysql:///prototype?cloudSqlInstance=${SQL_CONNECTION}&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=${SQL_USER:root}&password=${SQL_PASSWORD:root}
    hikari:
      maximum-pool-size: 4
server:
  port: ${PORT:8080}
---
spring:
  profiles:
    active: local
  datasource:
    url: jdbc:mysql://${SQL_CONNECTION:localhost}:3306/prototype?useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: root
    hikari:
      maximum-pool-size: 4
  jpa:
    hibernate:
      ddl-auto: update
    generate-ddl: true

server:
  port: 8080

logging:
  level:
    org:
      springframework:
        web: ERROR
        context: ERROR

---
spring:
  profiles:
    active: debug

logging:
  level:
    com:
      google:
        cloud:
          sql: DEBUG
    org:
      springframework:
        boot:
          autoconfigure:
            jdbc: DEBUG
        web: DEBUG
        context: DEBUG
      hibernate: DEBUG

我的logback.xml

<configuration>
    <springProfile name="!cloud, debug">
        <appender name="CONSOLE"
                  class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.classic.PatternLayout">
                <Pattern>
                    %black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] %yellow(%C{1.}): %msg%n%throwable
                </Pattern>
            </layout>
        </appender>
        <root level="info">
            <appender-ref ref="CONSOLE" />
        </root>
    </springProfile>
    <springProfile name="cloud">
        <appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender"/>
        <root level="info">
            <appender-ref ref="CLOUD" />
        </root>
    </springProfile>
</configuration>

0 个答案:

没有答案