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:
compile "org.apache.logging.log4j:log4j-api-kotlin:1.0.0" compile "org.apache.logging.log4j:log4j-api:2.11.1" compile "org.apache.logging.log4j:log4j-core:2.11.1"