How can I get logging dispatched from the response...
# ktor
a
How can I get logging dispatched from the response in KTor Client to respect the MDC entries I get in all other log entries? I have been digging around for hours, but almost losing my mind... πŸ™‚ I have looked for ways to set the coroutineContext for the HttpClitent etc. but I am getting lost in code. πŸ˜‰ Any pointers or solutions is much appreciated. πŸ™‚
πŸ‘€ 1
Never mind. After failing and failing I finally stumbled upon a combination that works.
Copy code
withContext(ktorClient.coroutineContext + MDCContext()) { ... }
πŸ₯³πŸ¦œπŸŽ‰
(MDCContext is in the coroutine-slf4j library)
o
Would you be willing to write a StackOverflow question with your own answer? You could save a lot of people a lot of time.
a
Yep, I can do that. Just wrapping up some related stuff that can go into the solution. πŸ™‚
Hey @okarm, what would be the "correct" way to do this? πŸ™‚ Just create a question with a ktor tag and then answer it myself directly after? πŸ™‚