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

Not work on Android #233

Closed
alessandroToninelli opened this issue Jul 8, 2022 · 16 comments
Closed

Not work on Android #233

alessandroToninelli opened this issue Jul 8, 2022 · 16 comments

Comments

@alessandroToninelli
Copy link

implementation 'io.github.microutils:kotlin-logging:2.0.11'
implementation 'org.slf4j:slf4j-simple:1.7.36'
implementation 'org.slf4j:slf4j-api:1.7.36'

With these library i can't see any log using Android

val klog = KotlinLogging.logger{}

@github-actions
Copy link

github-actions bot commented Jul 8, 2022

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

@alessandroToninelli alessandroToninelli changed the title No log on Android Not work on Android Jul 8, 2022
@oshai
Copy link
Owner

oshai commented Jul 8, 2022

Try using the dependency io.github.microutils:kotlin-logging-jvm instead of the first one (note the jvm at the beginning).
And you should also use slf4j-android and not slf4j-simple probably.

@alessandroToninelli
Copy link
Author

Same, not work with slf4j-android and kotlin-logging-jvm

@oshai
Copy link
Owner

oshai commented Jul 8, 2022

There is this example which was working in the past (but it uses the old kotlin-logging 1.x): https://github.com/MicroUtils/kotlin-logging-example-android

You can try that or spot the differences or create a newer repo to reproduce the issue.

@alessandroToninelli
Copy link
Author

i've already use this example but it still not work. the combination of libraries from that example does not work

@mipastgt
Copy link

I am using it all the time on desktop and Android and it works.
For Android just use the dependencies:

implementation("io.github.microutils:kotlin-logging-jvm:2.1.23")
implementation("org.slf4j:slf4j-android:1.7.35")

@alessandroToninelli
Copy link
Author

Not work

at this point it makes me think that I am doing something else wrong besides the dependencies

i declared a global variable in a file called KLogger.Kt like this:

val klog = KotlinLogging.logger {  }

@mipastgt
Copy link

This is not the intended usage. First try to follow the examples before you make your own experiments.

@alessandroToninelli
Copy link
Author

alessandroToninelli commented Jul 13, 2022

not the correct use?? tell me what changes at runtime my example from the one shown at the link https://github.com/MicroUtils/kotlin-logging-example-android/blob/master/app/src/main/java/mu/kotlinloggingexampleandroid/MainActivity.kt . And anyway using the examples shown on the page doesn't work.

@oshai
Copy link
Owner

oshai commented Oct 29, 2022

were you able to resolve the issue or still need assistance?

@oshai
Copy link
Owner

oshai commented Oct 29, 2022

here it is suggested to use slf4j-handroid.

@wuxianggujun
Copy link

我一直在台式机和Android上使用它,并且可以正常工作。 对于Android,只需要使用依赖项:

implementation("io.github.microutils:kotlin-logging-jvm:2.1.23")
implementation("org.slf4j:slf4j-android:1.7.35")

Thanks, I can print out the log with yours

@wuxianggujun
Copy link

This is my previous configuration and can't print logs at all
// implementation 'org.slf4j:slf4j-android:1.7.36' //implementation 'io.github.microutils:kotlin-logging-jvm:3.0.2'

@oshai
Copy link
Owner

oshai commented Dec 13, 2022

kotlin logging 3 is not compatible with slf4j 1.7.
it seems that slf4j-android doesn't have 2.x versions so I suspect it's not working anymore.
Try to find another implementation for slf4j 2 for android.

@oshai
Copy link
Owner

oshai commented Dec 16, 2022

See updates on #122 on how I plan to solve the issue.

@oshai
Copy link
Owner

oshai commented Feb 11, 2023

Version 4.0.0-beta-15 contains native android logging with artifact kotlin-logging-android.

@oshai oshai closed this as completed Feb 11, 2023
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

4 participants