使用 slf4j 简单记录器抑制调试日志

Suppress debug logs with slf4j simple logger

我正在使用 slf4j-simple。如何将 springfox 的默认日志级别设置为 info,同时保留所有其他来源的 debug 日志?

记录器属性文件位于此位置:

src
  main
    resources
      simplelogger.properties

simplelogger.properties:

logging.level.springfox=info
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.logFile=System.out

但是,我仍然以下列形式从 springfox 中获取多余的 debug 级日志:

[main] DEBUG springfox.documentation.schema.DefaultModelProvider - xxx

我可以通过将 simplelogger.properties 中的第二行更改为 org.slf4j.simpleLogger.defaultLogLevel=info 来抑制所有 debug 级别的日志,但我仍然想保留一些不是 debug 的日志由 springfox 生成。

来自the docs

org.slf4j.simpleLogger.log.a.b.c - Logging detail level for a SimpleLogger instance named "a.b.c". Right-side value must be one of "trace", "debug", "info", "warn", "error" or "off". When a SimpleLogger named "a.b.c" is initialized, its level is assigned from this property

因此,要在此包中设置记录器的日志级别:springfox 您应该在 simplelogger.properties 中设置此 属性:

org.slf4j.simpleLogger.log.springfox=info