0%
August 1, 2024

Logger in Kotlin

kotlin

springboot

Dependencies

implementation("io.github.oshai:kotlin-logging-jvm:5.1.0")

Code Implementation

import io.github.oshai.kotlinlogging.KLogger
import io.github.oshai.kotlinlogging.KotlinLogging
...

@Component
@ProcessingGroup("order-subscription-plan")
class SubscriptionPlanOrderEventHandlers(
    val stripCustomerDao: StripecustomerDao,
    val stripeorderDao: StripeorderDao,
) {
    companion object {
        var logger: KLogger = KotlinLogging.logger {}
    }
}

And we log the messages via logger.info { "Some Message" }.