Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems regarding Android #359

Open
mahozad opened this issue Sep 11, 2023 · 4 comments
Open

Problems regarding Android #359

mahozad opened this issue Sep 11, 2023 · 4 comments

Comments

@mahozad
Copy link

mahozad commented Sep 11, 2023

I'm using the library like this in my single-platform Android project:

build.gradle.kts

dependencies {
  implementation("io.github.oshai:kotlin-logging-android:5.1.0")
  implementation("org.slf4j:slf4j-android:1.7.36")
  testImplementation("org.slf4j:slf4j-simple:2.0.9")
  // ...
}

src/test/resources/simplelogger.properties:

# See https://stackoverflow.com/q/14544991/8583692
# and https://www.slf4j.org/api/org/slf4j/simple/SimpleLogger.html
org.slf4j.simpleLogger.logFile=System.out
org.slf4j.simpleLogger.defaultLogLevel=debug

It seems to be working fine for the most part. But there are some problems

First, the workaround above had not been mentioned anywhere.
I added testImplementation("org.slf4j:slf4j-simple:2.0.9") to prevent my unit tests from failing.
It is also a little bit cleaner in my opinion than using the following:

object Static {
    init {
        System.setProperty("kotlin-logging-to-android-native", "true")
    }
}
private val static = Static

And how about adding a section in the README of this repository for how to use the library in Android (and possibly other platforms)? Or at least, adding links to the example repositories?

The next problem is, there is no slf4j-android version 2 (as shown above) and it makes me a little uncomfortable.
It seems that SLF4J dropped the android module (see section April 7th, 2017 - Release of SLF4J 1.8.0-alpha0 in the release notes) apparently because of lack of interest from users.

Would you mind please opening an issue in SLF4j repository or issue tracker and request the android module to be brought back?

Another problem is that my integration tests are failing for some reason:

Unknown platform error occurred when running the UTP test suite. Please check logs for details.
com.android.ddmlib.TimeoutException

It's probably an ADB problem?
(the problem also existed when I checked out my previous git commits that had not included kotlin-logging library and they also failed)

@github-actions
Copy link

Thank you for reporting an issue. See the wiki for documentation and slack for questions.

@oshai
Copy link
Owner

oshai commented Sep 15, 2023

Thanks, I will see how to improve docs. If you have a cocrete idea a PR is welcome.

@mahozad
Copy link
Author

mahozad commented Sep 15, 2023

Thank you.

@CXwudi
Copy link

CXwudi commented Oct 19, 2024

There is an alternative fork of slf4j-android in https://github.com/nomis/slf4j-android, supports SLF4J 2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants