I'm writing a basic weather app mostly to just lea...
# getting-started
m
I'm writing a basic weather app mostly to just learn Kotlin. I'm at the point where I want to log some info to file instead of console. What are some mainstream logging utilities that people use in this space?
h
I like kotlin-logging by @oshai with Logback (but I'm only on the JVM)
r
It's going to depend a lot on which platform you are targeting
m
I'm currently just developing a desktop app but I might try to get it to run on iOS eventually. GitHub Copilot suggested this one... https://www.slf4j.org/
r
By platform we mean one or more of: • The JVM • WASM • Native ◦ Linux ◦ Windows ◦ macOs ◦ iOS • Android • JavaScript Desktop could be JVM, WASM, Native or JavaScript depending on which way you want to jump.
If you want your app to be multiplatform you probably want to write a KMP (Kotlin Multiplatform) project targeting whichever desktop you want at the moment via Kotlin Native, in which case I'd be surprised if SLF4J is any use to you, because it's very much a JVM library. But my KMP knowledge is very close to zero.
m
Good info. So if one were to want to eventually have an app that can run on both desktop (Windows) and iOS then KMP is the way to go, right? I know when I created my project that I did not select this option...
Otherwise, is there a way to see if I'm setup to use the JVM, WASM, Native, etc.? How do you choose between those options? Project settings?
r
I'd expect it to be a matter of which gradle plugin is applied in build.gradle.kts
m
I see. So I think this...
image.png
...means that I'm using the JVM as opposed to those other options (WASM, Native, Andriod, JavaScript).
There is one point that still confuses me a bit. When I create a new project in IDEA, the default seems to use the JVM and I do see that option for KMP. I didn't see a way to say... I want to do WASM|Native|JavaScript|Andriod.
r
I'm not familiar with the IntelliJ wizard, I just configure the gradle builds manually. I think on a KMP project you then state which targets you want it to build - see the page I linked. But I have zero experience with KMP so I'll bow out there. If you're happy to stay on the JVM, SLF4J with Logback as its implementation are my preferred ways of logging (though slf4j-simple is good enough if you just want to print to stdout).