【问题标题】:Configuring Spring Boot Logback配置 Spring Boot Logback
【发布时间】:2016-04-25 01:56:29
【问题描述】:

我正在尝试使用 Spring Boot 的日志记录配置编写 application.yml 文件。多亏了我上一个问题中的 Bal,我才能在 spring boot 的网站上查看sample file。因为我现在只想配置日志信息,所以我的 yml 文件现在看起来像这样:

# ===================================================================
# SPRING BOOT PROPERTIES
# ===================================================================


# LOGGING
logging:
  config: /logback.xml # Location of the logging configuration file. For instance `classpath:logback.xml` for Logback
  logging.level.org.springFramework=DEBUG # Log levels severity mapping. For instance `logging.level.org.springframework=DEBUG`
  path: # Location of the log file. For instance `/var/log`
  pattern:
    console: # Appender pattern for output to the console. Only supported with the default logback setup.
    file: # Appender pattern for output to the file. Only supported with the default logback setup.
    level: # Appender pattern for log level (default %5p). Only supported with the default logback setup.

但我有几个问题:

  1. 我应该在 yml 文件和 logback.xml 文件中做多少日志配置?是否应该将任何日志记录配置放在此处而不是全部放在 logback.xml 中?
  2. 日志级别配置行写对了吗?
  3. 我可以使用其他库的日志记录级别,例如 logback 吗?例如,我可以这样写:ch.qos.logback.classic.Level=DEBUG

【问题讨论】:

标签: java logging configuration spring-boot logback


【解决方案1】:
  1. 我不会将logback.xmlapplication.yml 结合使用。如果对您来说足够了,可以通过application.yml 使用简化配置,或者使用“全功能”logback.xml

说实话,我不确定当您在这两个文件中的配置相互矛盾时会发生什么(例如,不同的模式或日志级别)。

2 + 3。我猜你有额外的logging 部分。正确的例子是例如

logging:
  level:
    ch.qos.logback.classic: DEBUG
    org.hibernate: INFO

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 2017-05-17
    • 2019-08-16
    • 2014-10-12
    • 2018-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多