CommonsRequestLoggingFilter not working in spring boot application

I have been the same situation and I could resolve it with removing log setting.

logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG

It runs without this setting.

Also, if you want to change log level, you can define the class extends AbstractRequestLoggingFilter and write logging like this.

@Override
protected void beforeRequest(HttpServletRequest request, String message) {
    logger.info(message);
}

@Override
protected void afterRequest(HttpServletRequest request, String message) {
    logger.info(message);
}

Fyi if you see an extra ] at the end of the json body you can remove it like this:

loggingFilter.setAfterMessageSuffix("");

Try changing the level to TRACE in your application.properties file:

logging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=TRACE

DEBUG didn't work for me, but TRACE did.

Tags:

Spring Boot