我有以下dropwizard日志记录配置。
logging:
level: INFO
loggers:
com.company.test.api: WARN
com.company.app: INFO
appenders:
- type: file
threshold: INFO
timeZone: IST
logFormat: "%highlight(%-5level) [%date] [%thread] [%cyan(%logger{0})]: %message%n"
currentLogFilename: ./logs/test.log
archive: true
archivedLogFilenamePattern: ./logs/test-%d{yyyy-MM-dd-HH}.log
archivedFileCount: 50
- type: console
threshold: INFO
timeZone: IST
logFormat: "%highlight(%-5level) [%date] [%thread] [%cyan(%logger{0})]: %message%n"
我想在WARN
包中仅显示com.company.test.api
及以上的日志级别。但这不起作用。包括INFO
级别在内的所有日志都来自包。如何解决这个问题?
答案 0 :(得分:1)
我认为问题在于您在追加者中设置的阈值。
以下内容适用于我:
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: INFO
# Logger-specific levels.
loggers:
# Sets the level for package 'com.example.app' to DEBUG.
com.example.app: DEBUG
# Sets the level for 'org.eclipse.jetty.server.HttpChannel' to ERROR.
org.eclipse.jetty.server.HttpChannel: ERROR
appenders:
- type: console
threshold: ALL