I’ve installed logging feature, but it seems not w...
# ktor
g
I’ve installed logging feature, but it seems not working
Copy code
install(Logging) {
    logger = Logger.ANDROID
    level = LogLevel.ALL
}
Copy code
implementation "io.ktor:ktor-client-logging-jvm:$ktorVersion"
in logs I only see exception:
2020-03-05 16:16:33.829 1383-1383/? W/System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2020-03-05 16:16:33.829 1383-1383/? W/System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation
2020-03-05 16:16:33.829 1383-1383/? W/System.err: SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
is there a way to make it work ?
r
Logger.ANDROID is actually based on the default Ktor JVM logger which uses SLF4J and needs you to add that dependency. Alternatively you can use
Logger.SIMPLE
which just uses
println()
or create your own like
Copy code
logger = object : Logger {
    override fun log(message: String) {
        println(message) // or Log.d() or Timber.d() or whatever
    }
}
g
Thx, I’ll try to add slf4j dependency. I’ve followed documentation, but this info is missing
I made it work, but I’m missing logging levels for separate messages
c
These info should be added to the ktor logging page
👍 1