I'm using SpringBoot (spring-boot-starter-web 1.5.16.RELEASE) and hibernate-validator 6.0.11.Final in my REST service.
DTO objects annotated with proper validation constrains (UPDATE: I'm using @Valid annotation on controller's parameter) and validation works as expected.
I'd like to have all validation errors (that were send to the clients) logged in log files.
I assume there should be some simple way to enable that kind of messages (e.g. flag in app properties) but I can't find it anywhere.
Any suggestions would be appreciated.
It turned out that org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver does log the validation errors by default (and that is what I exactly need), e.g.
2018-10-18 12:54:25.552 WARN 22760 --- [nio-8092-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for
The reason why I haven't seen these messages was in log aggregation tool filters (i.e. I haven't seen messages in Kibana but they appear on local machine).
For those who will not see messages locally - check logging configuration and make sure that Spring logs are not muted there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With