Spring Boot - Disable validation logs

Viewed 815

Is there a way I can disable request parameter validation logs from showing up?

They look like the following:



2020-07-10 10:04:54.943  WARN 12071 --- [nio-8080-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public [REDACTED]: [Field error in object 'createDemoBootDto' on field 'firstName': rejected value [null]; codes [NotEmpty.createDemoBootDto.firstName,NotEmpty.firstName,NotEmpty.java.lang.String,NotEmpty]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [createDemoBootDto.firstName,firstName]; arguments []; default message [firstName]]; default message [must not be empty]] ]

Given that the application is going to be receiving a lot of requests it does not make sense to log every single validation error.

1 Answers

This behavior isn't enabled by default, so please check your application configuration for the following property:

spring.mvc.log-resolved-exception=true or spring.mvc.logResolvedException=true

And set it to false to disable the logging of resolved exceptions.

UPDATE: Depending on what version of Spring (and/or Spring Boot) you're using the DefaultHandlerExceptionResolver may have a mind of its own and overrides the setting. There's even an issue on GitHub about it. If my first solution doesn't work, can you try this one:

logging.level.org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver=ERROR
Related