Skip to main content

From other sources

Klogging can include context items from other sources without coroutine context information.

Klogging has a functional type alias ItemExtractor:

public typealias ItemExtractor = () -> EventItems

You can register an ItemExtractor to be called as each log event is assembled before it is emitted using Context.addItemExtractor function.

Klogging’s SLF4J provider uses an ItemExtractor to include any MDC entries into log event context items:

    Context.addItemExtractor {
MDC.getCopyOfContextMap() ?: mapOf()
}

Current MDC entries are included in all log events, whether sent from SLF4J loggers or direct from Klogger or NoCoLogger instances.