Proposal: SLF4J-like Logging Facade for Kotlin Mul...
# multiplatform
s
Proposal: SLF4J-like Logging Facade for Kotlin Multiplatform? Hi everyone, I’m wondering if there’s been any discussion around introducing a platform-agnostic logging facade for Kotlin Multiplatform, similar in spirit to what SLF4J is for the Java ecosystem. The idea would be to define a common logging interface in commonMain that doesn’t enforce any particular implementation – allowing platform-specific bindings (e.g. Logcat on Android, NSLog on iOS, console.log on JS, etc.), or integrations with existing libraries like Kermit or Napier. Such a facade could: • Encourage interface-driven logging across shared and platform code • Allow binding swap or mocking during testing • Provide a consistent API without favoring a specific logging backend • Reduce fragmentation across KMP libraries/projects using different solutions To be clear, I’m not talking about bringing SLF4J into KMP, but rather asking: Would it make sense to define a lightweight, SLF4J-style abstraction for logging in KMP? Has something like this already been discussed or attempted? Would like to hear your thoughts
m
s
@Mark This is not about a concrete implementation but rather a proposal for an abstract layer / facade for logging in KMP (provided by Kotlin).
👍 1
t
fyi @Filipp Zhinkin
thank you color 1
s
@tapchicoma I had the idea that it might be helpful if something like this were provided directly by Kotlin Core. I believe this could encourage broader adoption of the feature in third-party libraries and promote more consistent usage across the ecosystem.
5
m
Kotlin-logging, which was mentioned above, is not a pure facade. It builds upon SLF4J on JVM platforms but for other platforms it uses the platform native logging. So, it’s not a pure facade but is close enough for me.
s
@tapchicoma How do we proceed with this? Would you take up the topic and discuss it internally?
t
No, I am not responsible for this part. Though I shared your request internally.
👍 1
s
Thank you very much 🙏