Hello guys! I just adopted this amazing logger int...
# kotlin-logging
o
Hello guys! I just adopted this amazing logger into my project. I am writing a mini datadog that can be easily self-hosted and I'll publish it soon. I was attracted by this library because it seems it allows to define custom appenders. I have defined my custom appender successfully, however, I can't figure out how to add my new appender to the existing ones in my kotlin multiplatform app - common code. Any tip?
FYI that's how I've "resolved" it. 1. Create a custom appender that allows to go 1:N appenders
Copy code
class CompositeAppender(
    vararg appenders: Appender,
) : Appender {

    private val appenders = appenders.toSet()

    override fun log(loggingEvent: KLoggingEvent) {
        appenders.forEach { it.log(loggingEvent) }
    }

}
2. Init wrap the default one within the new one
Copy code
KotlinLoggingConfiguration.direct.logLevel = Level.TRACE
    KotlinLoggingConfiguration.direct.appender = CompositeAppender(
        KotlinLoggingConfiguration.direct.appender,
        CustomAppender1,
        CustomAppender2,
        ...
        CustomAppenderN,
    )
Let me know if I'm missing anything here. 🙂 I suspect that's not the intended way of doing it 😛