kotlin-logging is a MPP library that uses SLF4J on JVM, SLF4J is a facade to whatever implementation you choose. So I wouldn't be worried about 3 libraries. Does logback-android provide what you need. You can choose to use it with or without kotlin-logging as SLF4J is automatically included with logback. I believe kotlin-logging offer advantages that make logging code efficient and as unintrusive as possible.
m
Mark
02/11/2020, 1:11 PM
Thanks, and yes I didn’t realise that SLF4J doesn’t need to be explicitly specified as a dependency, so that’s nice.
Mark
02/11/2020, 1:17 PM
The way my custom logging worked was by calling inline functions like
Copy code
inline fun <reified T> T.logw(...)
but the problem with that is often T does not represent the tag you want (extension functions, coroutinescope or top-level functions). So having a top level logger property like
Copy code
val logger = KotlinLogging.logger {}
is so much better because that will use the filename as the tag (better for my needs)
Mark
02/12/2020, 5:46 AM
Hmm, actually it looks like I still need to explicitly specify the SLF4J dependency
c
corneil
02/12/2020, 5:47 AM
Interesting I thought that both kotlin-logging and logback have dependencies on SLF4J
m
Mark
02/12/2020, 6:34 AM
Apologies, it seems to be I was having some random build issue. Now working again without the explicit SL4J dependency!
👍 1
c
corneil
02/12/2020, 7:06 AM
Android Studio sync with Gradle isn't what it should be. I've found a restart is sometimes needed.