Michael Piefel
Michael Piefel

Reputation: 19998

Spring Boot and Logback: Disable a logger

Using Spring Boot 1.4 together with Logback, I configure the logging in the application.yml:

logging:
  level:
    org.hibernate.SQL: INFO
    com.netflix.eureka: OFF

Note that the recommendation for the second configuration comes straight from the Spring Cloud Service Registration and Discovery documentation. It works quite well for INFO and other ‘normal’ levels. However, the log also shows (reformatted by me):

… o.s.cloud.logging.LoggingRebinder        : Cannot set level: false for
        'org.hibernate.engine.internal.StatisticalLoggingSessionEventListener'

Now, false is a very interesting level, isn’t it? How can I disable a logger completely?

Upvotes: 13

Views: 4462

Answers (1)

Pete
Pete

Reputation: 807

The yaml-parser interprets the words OFF and ON as Boolean and so passes false or true to the logging framework. If you want to disable logging with the level OFF you need to set the value of the property as a String which can be achieved by single quotes. Your example modified:

logging:
  level:
    org.hibernate.SQL: INFO
    com.netflix.eureka: 'OFF'

Upvotes: 26

Related Questions