Spring Framework logs binding / validation errors as WARN irrespective of whether the exception has @ExceptionHandler
to take appropriate action or not. In such cases, the warning may be redundant for the users as they already have explicit handling in place and don't need to take any further action.
In any reasonably sized application this could significantly increase the log file size without adding much value.
2024-01-18 12:55:32.434 [tomcat-handler-0] WARN org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public org.springframework.http.ResponseEntity<dev.all_things.reference.app.authentication.web.AuthenticationController$AuthenticationResponse> dev.all_things.reference.app.authentication.web.AuthenticationController.login(dev.all_things.reference.app.authentication.web.AuthenticationController$AuthenticationRequest): [Field error in object 'authenticationRequest' on field 'password': rejected value [null]; codes [NotNull.authenticationRequest.password,NotNull.password,NotNull.java.lang.String,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [authenticationRequest.password,password]; arguments []; default message [password]]; default message [must not be null]] ]
I think it will be nice if users have an option to log these messages as DEBUG or skip it altogether.
P.S.
I understand that expected behavior can be achieved by configuring logger for org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver
but that could lead to users missing genuine warnings as well.
Spring Boot: 3.2.1 Spring Framework: 6.1.3
Comment From: rstoyanchev
ExceptionHandlerExceptionResolver
does not log resolved exceptions by default. There is a warnLogger
that must be explicitly enabled by setting the setWarnLogCategory(String)
property. The property is there for those who actually do want to see resolved exceptions.
So check your configuration. Spring Boot provides a property called spring.mvc.log-resolved-exception
but that's also false
by default, or perhaps you have devtools included. I'm closing because from a Spring Framework perspective this message can only appear by choice.