0
votes

Recently upgraded from Spring-Boot 1.5.6.RELEASE to 1.5.8.RELEASE

On doing so, we noticed the environment was being logged out as "DEBUG" and category "StandardServletEnvironment".

However, the application.properties file does not specify logging at DEBUG level. Even explicitly setting a level of warning or error for that class does not make a difference.

The code that is doing the logging is in the constructor of org.springframework.core.env.AbstractEnvironment:

public AbstractEnvironment() {
        customizePropertySources(this.propertySources);
        if (logger.isDebugEnabled()) {
            logger.debug("Initialized " + getClass().getSimpleName() + " with PropertySources " + this.propertySources);
        }
    }

Debug is not enabled, yet it logs. It seems as if it is doing this before it reads the log levels from application.properties.

Is there any explanation for this, or a way around this?

The application.properties has:

logging.level.root=INFO
logging.level.com.mycompany=DEBUG

In the code, I see a comment about logging initialization being deferred.

1
Can you share your application.properties?SrThompson
I've added the logging lines to the question. Other than that, it does not have much: management.security.enabled=false, endpoints.health.sensitive=false, management.health.defaults.enabled=falseDarius X.

1 Answers

0
votes

I managed to suppress this error by creating my own WebApplicationInitializer class, in which I explicitly set the offending log-category to a log-level of INFO

class MyWebApplicationInitializer implements WebApplicationInitializer{
    @Override
    void onStartup(ServletContext servletContext) throws ServletException {

        String category = 'org.springframework.web.context.support.StandardServletEnvironment'

        ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) org.slf4j.LoggerFactory.getLogger(category)
        logbackLogger.setLevel(ch.qos.logback.classic.Level.INFO)
        logbackLogger.info("Setting log level in ${this.class.name}, for ${logbackLogger.name}, to ${logbackLogger.level}")
}

It feels like a hack. So, if someone has a better answer, please post.