tamas-bazsonyi.jpg

Lightweight logging for Kotlin Multiplatform

Romain Boisselle

Logging has always been a more complex task than it seems, so logging in a Kotlin/Multiplatform app, using different logger backends can be especially frustrating.

From simple messages to stack traces, classification tags, package shortening, and log filtering, we introduce a simple, functional tool that works on each platform Kotlin can compile to.

First, we will introduce Kodein-Log and demonstrate its simple and elegant API. We will show how it integrates with each platform’s default logging tool, and how you can replace or inject a new log receiver.

Then, we will tackle more complex tasks, such as level or package filtering, package shortening, secret removal and other kinds of transformers and data enhancers.

Finally, we will show how to abstract this configuration in a Kotlin/Multiplatform project in order to reuse it on each target, whatever the actual backend receiver. By the end of this talk, you should be able to easily log everything in your app, and focus on your business code, rather than on its reporting.