Meta-note: I can't add the Kotlin tag since I have less than 300 rep on this site, and it doesn't exist yet

I'm working on a cross-platform project written in Java and Kotlin, and I need some decent logging. System.out isn't in my opinion a good way to deal with logging, so I'm looking for a cross-platform logging library.

Specifically, it has to work for desktop and Android.

The project structure itself looks like this:

  • Project
    • Core - shared code for Android and desktop
    • Android (implementation project(":core")), platform-specific Android stuff (passed to core)
    • Desktop (implementation project(":core")), platform-specific desktop stuff (passed to core)

Which means the library has to work on both Android and desktop, since the majority of the code base is shared (platform-specific calls would crash it for obvious reasons, which is why it either needs to have a specific port for each of the platforms, but still supporting a central implementation, or work universally with both platforms).

The library doesn't need to be written in Java or Kotlin, but it has to be written in a JVM language (Java, Kotlin, Scala, Groovy, etc.)

1 Answer 1



I use java standard logging lib slf4j

  • 'org.slf4j:slf4j-api:1.7.7@jar' the logging api included in all code
  • 'eu.lp0.slf4j:slf4j-android:1.7.7-1@jar' include in the android app: android specific implementation of slf4j
  • 'org.slf4j:slf4j-simple:1.7.7' include in non-android app: j2se implementation of slf4j
  • your android app also needs a file "...\app\src\main\resources\eu\lp0\slf4j\android\config.properties" which configures which loggers are active
  • I used 1.7.25 for the version though (1.7.25-1 for the Android one). It's probably worth mentioning the Android port changed the package to uk.uuid.slf4j. Did some research on slf4j when trying to figure out the properties and stumbled over logback (which runs as the desktop "port" of the logger), so I use that instead of slf4j-simple. Still using slf4j though, the logs seem to work on Android and desktop without much problem. Thanks!
    – user36601
    Jun 11, 2018 at 18:50
  • 1
    @Zoe Logback is written by the same author as slf4j. The slf4j library is meant to be used as a façade in front of a logging framework. Logback is intended to be a direct implementation of the slf4j API. So Logback is generally the best choice for a greenfield project. By using calls to slf4j throughout your app, you give yourself the freedom to switch to another framework should Logback ever cease development or no longer meet your needs. Other logging frameworks can be made to work with slf4j by way of an adapter. The slf4j-simple implementation is just to get you started, for learning/demo. Jun 13, 2018 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.