https://kotlinlang.org logo
Title
l

legzo

04/01/2019, 11:15 AM
Hi guys, I was wondering if there is a way to achieve the following : I have an HTTPClient that calls back-end REST services and tries to read the response as a particular type T. I have installed the ClientLogging feature and everything works as expected, unless the server returns an error, for example an authorization issue, the response cannot be read as T and and exception is thrown, leaving me with no logs. It's a bit hard to debug... As I understand, ClientLogging intercepts at
HttpReceivePipeline.Before
with a
ResponseObserver
and I don't really understand why my back-ends' logs aren't showing up. Anyone has a clue ?
e

e5l

04/01/2019, 11:16 AM
Hi @legzo, the exception logging is fixed and would be available in the next release.
👍 1
l

legzo

04/01/2019, 11:17 AM
Ah ! I thought I missed something ! Is it in the CallLogging feature (and maybe I can cherrypick it ?) or is it in ktor's core ?
In fact I don't know if I was clear : what I miss is the possibility to see the response raw body in the logs. And I think the commit you pointed out only adds a log stating that something failed right ?
:yes: 1
And do you have a suggestion to how I could implement logging the response body ?
What I don't get is that
HttpReceivePipeline.Before
is the earliest phase but I don't see the logs even though my code is the following :
val response = client.request<HttpResponse> { ... }

// here I don't see any log

when (response.status) {
     OK -> result = response.receive<T>()  // here the exception is thrown