Satyam Agarwal
02/03/2020, 8:51 PMIO.dispatchers().io() and I am logging there as well, I want to tie them with MDC. Here is how I am trying, since kotlin has an mdc-slfj wrapper called
org.jetbrains.kotlinx:kotlinx-coroutines-slf4j
that applies the matching mdc value on the new started coroutine, like this :
MDC.put("mdc-key", "unique-mdc-value")
withContext(MDCContext()) { //withContext and MDCContext() comes from above library
yourJobOrWhatever()
}
So I thought to apply something like this :
IO.effect(IO.dispatchers().io()) {
withContext(MDCContext()) {
<http://log.info|log.info>("whatever")
}
}
But this doesn’t work. As I have understood I need to add the new coroutine started inside withContext to IO.dispatchers().io() for it to work. But maybe I am wrong. If anyone has ideas. It will be amazing. 🙂