https://kotlinlang.org logo
#ktor
Title
# ktor
g

gabin

03/05/2020, 4:56 PM
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

russhwolf

03/05/2020, 5:04 PM
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

gabin

03/05/2020, 5:06 PM
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

coletz

03/11/2020, 11:55 PM
These info should be added to the ktor logging page
👍 1
7 Views