Search code examples
loggingslf4jspringfox

Suppress debug logs with slf4j simple logger


I am using slf4j-simple. How do I set the default log level for springfox to info, while keeping debug logs from all other sources?

The logger properties file is in this location:

src
  main
    resources
      simplelogger.properties

simplelogger.properties:

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

However, I am still getting excess debug level logs from springfox in the following form:

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

I can suppress all debug level logs by changing the second line in simplelogger.properties to org.slf4j.simpleLogger.defaultLogLevel=info, but I still want to keep some debug logs that are not generated by springfox.


Solution

  • From 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

    So, to set the log level for loggers in this package: springfox you should set this property in simplelogger.properties:

    org.slf4j.simpleLogger.log.springfox=info