Log4j2 for Kotlin


Logging is a common good practice in software engineering. It enables you to monitor applications in production to gather information about crashes and other malfunctions for further analysis. It is the “little brother” of debugging and often a precursor for setting up test cases which can lead to reproducing the bugs on the developers machine.

Log4j2 is version 2 of the very famous Apache logging library log4j from the Java ecosystem.

This article describes a minimal working solution for log4j2 with Kotlin and Gradle.


To get started with log4j2 add the following lines to your build.gradle file in the dependency section:

implementation 'org.apache.logging.log4j:log4j-api:2.15.0'
implementation 'org.apache.logging.log4j:log4j-core:2.15.0'

Please make sure to use the latest 2.15.0 2.16.0 to avoid the Zero-Day Exploit! More Details


Continue reading “Log4j2 for Kotlin”