Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 417
Michael Piefel Avatar asked Sep 13 '16 12:09

Michael Piefel


1 Answers

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'
like image 188
Pete Avatar answered Oct 04 '22 15:10

Pete