# How to get validation error logged?

**URL:** <https://discuss.akka.io/t/how-to-get-validation-error-logged/7995>\
**Category:** Akka Libraries\
**Created:** [March 15, 2021, 11:53am UTC](https://discuss.akka.io/t/how-to-get-validation-error-logged/7995 "2021-03-15T11:53:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![strowk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/strowk/32/2243_2.png) [@strowk](https://discuss.akka.io/u/strowk)\
**Post date:** [March 15, 2021, 11:53am UTC](https://discuss.akka.io/t/how-to-get-validation-error-logged/7995/1 "2021-03-15T11:53:23Z")

</div>

Hi! We are using akka-http and I recently had to rewrite one of our validations from simple if-else to this method - [validate • Akka HTTP](https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/misc-directives/validate.html) . It totally works, but I don’t understand how can I add a log message (by calling slf4j for example) in case if we had an invalid input. Is there a way to add some sort of “onFail” lambda or something like this?  
I’d also like to increase specific metric (kamon) when this happens, but if only log is possible, that is also fine.

---

<div class="post-metadata">

**Author:** ![strowk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/strowk/32/2243_2.png) [@strowk](https://discuss.akka.io/u/strowk)\
**Post date:** [March 15, 2021, 12:30pm UTC](https://discuss.akka.io/t/how-to-get-validation-error-logged/7995/2 "2021-03-15T12:30:58Z")

</div>

Ah, I used this one - [handleRejections • Akka HTTP](https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/execution-directives/handleRejections.html) . Seems nice
