January 08, 2024

Google Summer of Code 2023 - KFlogger (Kotlin Multiplatform Flogger)

The Kotlin Foundation sponsored 4 projects for the Google Summer of Code 2023 and we are excited to announce the completion of the KFlogger project, an experimental Kotlin Multiplatform version of Google's Flogger logging library! The contributor to this project was Giancarlo Buenaflor, a computer science undergraduate, and the mentor was Mark Mann, a Kotlin Multiplatform engineer at Google.


Flogger, Google's default logging framework for JVM projects, opens up new opportunities for efficient cross-platform logging. The KFlogger project aims to enable the integration of Flogger into iOS and JVM, benefitting from the multiplatform capabilities of Kotlin.

KFlogger incorporates the existing JVM Flogger codebase as a Java module, preserving its core functionality. The JVM implementation remains largely untouched and is directly actualized through the actual typealias mechanism. On the iOS side, KFlogger introduces a default logging backend based on OSLog.

Here is a demo of this working on Android and iOS:

Getting Started

To use KFlogger, add the following dependency to your commonMain sourceSet:

// Find the latest version 
// on https://mvnrepository.com/artifact/com.giancarlobuenaflor/kflogger

This will allow you to start simple logging. Add the KFluentLogger instance to your class and then you can start logging through your common code:

import com.giancarlobuenaflor.kflogger.KFluentLogger

class LoggingClass {
    private val logger = KFluentLogger.forEnclosingClass()
    fun log() {
        logger.atWarning().log("string: %s", "example")
        logger.atWarning().log("integer: %d:", 1)
        logger.atWarning().log("float: %f", 1.0f)
        logger.atWarning().log("%d%% %s", 100, "chance")

The source is in a GitHub repository and we'd love your feedback and contributions!

Thank you Giancarlo and Mark for helping make Kotlin Multiplatform even better!

Still have questions?
Contact us!