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

Daniele B

02/18/2021, 3:17 PM
Running commonTest in a KMM project: when I call a function that uses Ktor Client I get this warning:
Copy code
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
is it normal?
c

CLOVIS

02/18/2021, 4:10 PM
What are your dependencies? You need a logger implementation if you want logging.
d

Daniele B

02/18/2021, 4:25 PM
I just realized that the warning also happens when I run the app normally, not just while testing
In commonMain I have this dependency:
Copy code
implementation("io.ktor:ktor-client-logging:1.5.1")
These are all the Ktor dependencies I have in CommonMain:
Copy code
implementation("io.ktor:ktor-client-core:${Versions.ktor}")
implementation("io.ktor:ktor-client-json:${Versions.ktor}")
implementation("io.ktor:ktor-client-logging:${Versions.ktor}")
implementation("io.ktor:ktor-client-serialization:${Versions.ktor}")
c

CLOVIS

02/18/2021, 5:53 PM
One way to fix that issue: https://gitlab.com/braindot/clovis/-/blob/master/server/build.gradle.kts It really depends on which engine you want to use
If you want to go with Log back, you will also need this file: https://gitlab.com/braindot/clovis/-/blob/master/server/src/main/resources/logback.xml
d

Daniele B

02/18/2021, 6:03 PM
I am using Ktor Client on a multiplatform project, on commonMain. It seems logback is JVM only. So, I don’t think I can add it as a dependency in CommonMain.
Is everyone using Ktor Client on Common Main having the same issue?
c

CLOVIS

02/18/2021, 7:44 PM
Oh, the only two times I had this issue were JVM-only projects. Maybe there are other artifacts for other platforms, not sure.
d

Daniele B

02/18/2021, 8:48 PM
I was running an Android app, so that's why
a

andylamax

02/26/2021, 7:04 AM
@Daniele B Yes and that warning is only printed when running on jvm. Other platforms don't get that warning. Adding logback to the jvm and/or android target should solve your problem
d

Daniele B

02/26/2021, 9:38 AM
Yes, I also realized, thanks
6 Views