【问题标题】:Default Spring Boot log4j2 log pattern默认 Spring Boot log4j2 日志模式
【发布时间】:2016-08-01 09:30:06
【问题描述】:

Spring boot 附带了几个默认的日志框架配置,包括 Log4j2。虽然 Spring boot 参考手册中有关于日志记录的详细文档,但没有提及默认日志模式的配置方式和位置,因此很难覆盖它。

问题是Spring Boot在哪里配置Log4j2的默认日志模式?

到目前为止,我已经查看了 Spring Boot 的以下几个地方:

AutoConfigurationReportLoggingInitializer
LoggingApplicationListener
SimpleFormatter
LoggingSystem
Log4J2LoggingSystem

【问题讨论】:

    标签: spring-boot log4j2


    【解决方案1】:

    似乎没有在任何 Java 类中完成 Log4J2 配置,所以我看错了地方。 Spring Boot 附带两个文件log4j2.xmllog4j2-file.xml,它们包含默认配置,可以在org.springframework.boot.logging.log4j2 中找到。

    【讨论】:

    • 这两个文件有什么区别 - log4j2.xml vs log4j2-file.xml
    • log4j2-file.xml 具有附加配置,该配置还将记录到给定文件或给定目录中的多个文件,具体取决于是否设置了 LOG_FILE 或 LOG_PATH 系统属性。见github.com/spring-projects/spring-boot/tree/main/…
    猜你喜欢
    • 2015-11-03
    • 1970-01-01
    • 2022-10-20
    • 2015-08-14
    • 2020-10-18
    • 1970-01-01
    • 2021-11-19
    • 2017-12-20
    • 2014-10-30
    相关资源
    最近更新 更多