kotlin-logging alternatives and similar libraries
Based on the "Misc" category.
Alternatively, view kotlin-logging alternatives based on common mentions on social networks and blogs.
-
jclasslib
jclasslib bytecode editor is a tool that visualizes all aspects of compiled Java class files and the contained bytecode. -
kotlin-telegram-bot
๐ค A wrapper for the Telegram Bot API written in Kotlin -
kotlinx.atomicfu
The idiomatic way to use atomic operations in Kotlin -
tinylog
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android -
lingua
The most accurate natural language detection library for Java and the JVM, suitable for long and short text alike -
Kotlift
Kotlift is the first source-to-source language transpiler from Kotlin to Swift -
kotlinx.reflect.lite
Lightweight library allowing to introspect basic stuff about Kotlin symbols -
Humanizer.jvm
Humanizer.jvm meets all your jvm needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities. -
actions-on-google-kotlin
Unofficial Actions on Google SDK for Kotlin and Java -
klutter
A mix of random small libraries for Kotlin, the smallest reside here until big enough for their own repository. -
solr-undertow
Solr / SolrCloud running in high performance server - tiny, fast startup, simple to configure, easy deployment without an application server. -
kassava
This library provides some useful kotlin extension functions for implementing toString(), hashCode() and equals() without all of the boilerplate. -
SimpleDNN
SimpleDNN is a machine learning lightweight open-source library written in Kotlin designed to support relevant neural network architectures in natural language processing tasks -
units-of-measure
Type-safe dimensional analysis and unit conversion in Kotlin. -
TLSLibrary
Simple TlsLibrary written in Kotlin - Provides DSL for creating TLS connections -
kotlin-futures
A collections of extension functions to make the JVM Future, CompletableFuture, ListenableFuture API more functional and Kotlin like. -
scientist
A kotlin library for refactoring code. Port of GitHub's scientist. -
kasechange
๐ซ๐๐ข๐ ฟ Multiplatform Kotlin library to convert strings between various case formats including Camel Case, Snake Case, Pascal Case and Kebab Case -
kjob
A lightweight coroutine based persistent job/cron scheduler written in Kotlin -
KDispatcher
Simple and light-weight event dispatcher for Kotlin -
PrimeCalendar
PrimeCalendar provides all of the java.util.Calendar functionalities for Persian, Hijri, and ... dates. It is also possible to convert dates to each other. -
kotlin-pluralizer
:sunny: Kotlin extension to pluralize and singularize strings -
aleksa
Aleksa is a small framework for writing Alexa Skills in Kotlin -
kformula
Mathematical expression engine written in Kotlin, running on JVM. -
kase-format
Multiplatform kotlin string case conversion and detection library.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of kotlin-logging or a related project?
README
kotlin-logging

Lightweight logging framework for Kotlin, written in .
A convenient and performant logging library wrapping slf4j with Kotlin extensions.
Call log methods, without checking whether the respective log level is enabled
logger.debug { "Some $expensive message!" }
Behind the scenes the expensive message do not get evaluated if debug is not enabled:
// This is what happens when you write the above ^^^
if (logger.isDebugEnabled) logger.debug("Some $expensive message!")
Define the logger, without explicitly specifiying the class name
// Place definition above class declaration to make field static
private val logger = KotlinLogging.logger {}
Behind the scenes val logger
will be created in the class, with the class/file name:
// This is what happens when you write the above ^^^
val logger = LoggerFactory.getLogger("package.ClassName")
Log exceptions in a Kotlin-style
// exception as first parameter with message as lambda
logger.error(exception) { "a $fancy message about the $exception" }
Getting started
import mu.KotlinLogging
private val logger = KotlinLogging.logger {}
class FooWithLogging {
val message = "world"
fun bar() {
logger.debug { "hello $message" }
}
}
An Android
example project with kotlin-logging can be found in kotlin-logging-example-android.
Download
Important note: kotlin-logging depends on slf4j-api (in the JVM artifact). In runtime, it is also required to depend on a logging implementation. More details in how-to-configure-slf4j. And an excellent detailed explanation in a-guide-to-logging-in-java.
In short, if you just want to log statements to stdout, it's possible to add the following dependency: org.slf4j:slf4j-simple:2.0.3
.
Maven
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
<version>3.0.2</version>
</dependency>
See the full example in kotlin-logging-example-maven.
Gradle
implementation 'io.github.microutils:kotlin-logging-jvm:3.0.2'
Alternatively, download the JAR from github or bintray or maven-central.
Multiplatform
An experimental common & JS & linux-x64 support is available.
More information is available on the wiki and issues #21 #45.
Overview
After seeing many questions like Idiomatic way of logging in Kotlin and Best practices for loggers, it seems like there should be a standard for logging and obtaining a logger in Kotlin. kotlin-logging provides a wrapper for slf4j-api to be used by Kotlin classes with the following advantages:
- No need to write the logger and class name or logger name boilerplate code.
- A straight forward way to log messages with lazy-evaluated string using lambda expression
{}
. - All previous slf4j implementation can still be used.
Who is using it
- https://www.jetbrains.com/youtrack/ (https://www.jetbrains.com/help/youtrack/standalone/Third-Party-Software-Used-by-YouTrack.html)
- https://github.com/DiUS/pact-jvm
- https://github.com/AsynkronIT/protoactor-kotlin
- https://github.com/square/misk
- https://github.com/openrndr/openrndr
- https://github.com/JetBrains/xodus
And many more... (add your name above)
FAQ
- Why not use plain slf4j? kotlin-logging has better native Kotlin support. It adds more functionality and enables less boilerplate code.
- Is all slf4j implementation supported (Markers, params, etc')? Yes, kotlin-logging inherits Logger and all methods are supported.
- Is location logging possible? Yes, location awareness was added in kotlin-logging 1.4.
- When I do
logger.debug
, my IntelliJ IDEA run console doesn't show any output. Do you know how I could set the console logger to debug or trace levels? Is this an IDE setting, or can it be set in the call to KLogging()? Setting log level is done per implementation. kotlin-logging and slf4j are just facades for the underlying logging lib (log4j, logback etc') more details here. - Can I access the actual logger? Yes, via
KLogger.underlyingLogger
property.
Usage
- See wiki for more examples.
It is possible to configure IntelliJ live templates. For file level logger configure the following:
- Text template:
private val logger = mu.KotlinLogging.logger {}
. - Applicable in
Kotlin: top-level
.
Support
- Open an issue here: https://github.com/MicroUtils/kotlin-logging/issues
- Ask a question in StackOverflow with kotlin-logging tag.
- Chat on Slack channel: https://kotlinlang.slack.com/messages/kotlin-logging
- Chat on Telegram channel: https://t.me/klogging
More links
- https://medium.com/@OhadShai/logging-in-kotlin-95a4e76388f2
- kotlin-logging vs AnkoLogger for Android
- How kotlin-logging was published
- Kotlin Logging Without the Fuss
- DropWizard + Kotlin = Project Kronslott
- Logging in Kotlin โ the right approach
- https://bednarek.wroclaw.pl/log4j-in-kotlin/
- https://jaxenter.com/kotlin-logging-168814.html
Contributing
Any contribution is appreciated.
See the contributors list in: https://github.com/MicroUtils/kotlin-logging/graphs/contributors
Pull requests are welcome! See instructions in https://github.com/MicroUtils/kotlin-logging/blob/master/CONTRIBUTING.md.
*Note that all licence references and agreements mentioned in the kotlin-logging README section above
are relevant to that project's source code only.