with Logging Context
Use a pair in MDC context. Example:
withLoggingContext("userId" to userId) {
doSomething()
}
withLoggingContext("userId" to userId, restorePrevious = false) {
doSomething()
}
Use a vary number of pairs in MDC context. Example:
withLoggingContext("userId" to userId) {
doSomething()
}
Use a map in MDC context. Example:
withLoggingContext(mapOf("userId" to userId)) {
doSomething()
}
withLoggingContext(mapOf("userId" to userId), restorePrevious = true) {
doSomething()
}