kotlin-logging is a MPP library that uses SLF4J on...
# kotlin-logging
c
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
Thanks, and yes I didn’t realise that SLF4J doesn’t need to be explicitly specified as a dependency, so that’s nice.
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)
Hmm, actually it looks like I still need to explicitly specify the SLF4J dependency
c
Interesting I thought that both kotlin-logging and logback have dependencies on SLF4J
m
Apologies, it seems to be I was having some random build issue. Now working again without the explicit SL4J dependency!
👍 1
c
Android Studio sync with Gradle isn't what it should be. I've found a restart is sometimes needed.
👍 1
133 Views