Hi François,

probably the problem is that the exception is only converted into a
response when the route is "sealed". This happens automatically when you
pass a route to `bindAndHandle`. Otherwise, you will have to manually seal
the route to see responses with logRequestResponse.

See
https://doc.akka.io/docs/akka-http/current/routing-dsl/routes.html#sealing-a-route
for more information about sealing a route.

We are also working on https://github.com/akka/akka-http/issues/2216 which
will hopefully soon provide a lower-level, more reliable way to log all
outgoing responses.

Johannes

On Thu, Dec 20, 2018 at 12:09 PM François Vatel <vatel...@gmail.com> wrote:
>
> Hello,
>
> I am using latest akka-http and have routing like this:
>
> val httpRoute =
>   logRequestResult(showRequestResponse _) {
>     pathPrefix("rpc") {
>
>       session() { session =>
>
>          ...
>
>       }
>     } ~
>   }
>
>
> def showRequestResponse(request: HttpRequest) = {
>     val startTime = DateUtils.now()
>     val requestId = StringUtils.uniqueRandomKey(16, true)
>
>     logger.debug(s"Request($requestId) is: " + request)
>
>     (response: Any) => {
>       val handlingTime = (DateUtils.now() - startTime).toInt
>       logger.debug(s"Response($requestId)($handlingTime ms) is: " +
response)
>       None
>     }
>   }
>
>
> "session" is a hand-made directive which creates some kind of Session
object from cookies.
>
> The problem is that the response is not logged if I throw an Exception
(which is correctly mapped to a response with status 401). What is wrong
here?
>
> --
>
*****************************************************************************************************
> ** New discussion forum: https://discuss.akka.io/ replacing akka-user
google-group soon.
> ** This group will soon be put into read-only mode, and replaced by
discuss.akka.io
> ** More details:
https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
>
*****************************************************************************************************
> >>>>>>>>>>
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
"Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.



--
Akka Team
Lightbend - Reactive apps on the JVM
Twitter: @akkateam

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to