Running commonTest in a *KMM project*: when I call...
# ktor
d
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
What are your dependencies? You need a logger implementation if you want logging.
d
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
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
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
Oh, the only two times I had this issue were JVM-only projects. Maybe there are other artifacts for other platforms, not sure.
d
I was running an Android app, so that's why
a
@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
Yes, I also realized, thanks