Ktor needs an SLF4J implementation for logging to ...
# multiplatform
l
Ktor needs an SLF4J implementation for logging to work. For Android there is Logback. How do you handle logging on iOS? Is it possible to use Kermit for Ktor logging there?
m
You can use Kermit in both iOS and Android. Something like
Copy code
class KtorLogger(private val kermit: Kermit) : Logger {
    override fun log(message: String) {
        kermit.d { message }
    }
}
r
ktor doesn't require an slf4j implementation. It just looks for one by default. If you inject your own logger (Kermit, just calling Logcat, or whatever else) it will work fine without slf4j or logback
l
Ok, great, thanks for your support.
The Ktor documentation is a little unprecise on this topic. Actually I figured you can just inject Ktor's own
Logger.SIMPLE
and it will just print the log messages to the console both on Android and iOS. However if you inject
Logger.DEFAULT
as the documentation says it won't work on Android...
r
Yeah I think
DEFAULT
is the one that tries to do slf4j on JVM
👍 1
m
You can use Klogging as an SLF4J implementation in Ktor. Currently only JVM but planned to expand to other platforms (when I have time). https://klogging.io/docs/java/slf4j
217 Views