【问题标题】:How to check logging implementation details in Spring Boot如何在 Spring Boot 中检查日志记录实现细节
【发布时间】:2019-02-11 13:43:20
【问题描述】:

我正在使用Spring boot

我想检查哪个日志记录实现正在打印消息 - 我知道 Spring boot 默认是 Logback,并且我已将其排除在 this 帖子中,因此大部分 Logback 不会打印消息,但我想要将其作为 Logback 实现未打印并且可能 Log4j 正在打印的证据。

基本上我需要一个我可以调用的 API,我可以获取日志实现的详细信息,我们可以知道 Java 版本等的方式。

【问题讨论】:

    标签: java spring spring-boot logging


    【解决方案1】:

    你可以通过设置这个属性来强制 Spring Boot 使用某个实现:

    org.springframework.boot.logging.LoggingSystem
    

    任何一个:

    • org.springframework.boot.logging.logback.LogbackLoggingSystem
    • org.springframework.boot.logging.log4j2.Log4J2LoggingSystem
    • org.springframework.boot.logging.java.JavaLoggingSystem
    • 无(完全关闭)

    这个明确的配置就是你的证明。

    【讨论】:

    • 那么,这意味着如果我打印 org.springframework.boot.logging.LoggingSystem 值,那么它会告诉我的日志记录实现?
    • 我打印了它现在打印 NULL ......那么我怎么能确定一旦我设置了它就会使用那个实现......我的期望是它应该打印一些东西
    • 您只需在 application.properties 中设置它,Spring 就会明确使用该实现
    【解决方案2】:

    要检查配置,您可以安装弹簧执行器框架。通过 Web 端点可以查询所有配置参数。

    【讨论】:

    • 我试过这种方法,但是执行器框架不显示默认的日志实现框架名称(因为 org.springframework.boot.logging.LoggingSystem 为空?)
    猜你喜欢
    • 2019-03-25
    • 2015-09-10
    • 2017-12-26
    • 2017-11-01
    • 2019-08-31
    • 2019-01-06
    • 2017-09-17
    • 1970-01-01
    • 2017-01-26
    相关资源
    最近更新 更多