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

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory #361

Closed
sleeyax opened this issue Sep 24, 2023 · 2 comments

Comments

@sleeyax
Copy link

sleeyax commented Sep 24, 2023

I just installed the library and used it like in the README:

build.gradle.kts:

 implementation("io.github.oshai:kotlin-logging-jvm:5.1.0")

manager.kt:

private val logger = KotlinLogging.logger {}

class Manager {
    fun xxx() {}
}

But I can't get it working at all. As soon as I try to run my program I get:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at io.github.oshai.kotlinlogging.slf4j.internal.Slf4jLoggerFactory.jLogger$kotlin_logging(Slf4jLoggerFactory.kt:11)
	at io.github.oshai.kotlinlogging.internal.KLoggerFactory.logger$kotlin_logging(KLoggerFactory.kt:16)
	at io.github.oshai.kotlinlogging.KotlinLogging.logger(KotlinLogging.kt:23)
	at io.github.oshai.kotlinlogging.KotlinLogging.logger(KotlinLogging.kt:13)
	at com.sleeyax.ManagerKt.<clinit>(Manager.kt:12)
	at com.sleeyax.Manager.xxx(Manager.kt:17)
	at com.sleeyax.MainKt.main(Main.kt:14)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 7 more
@github-actions
Copy link

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

@sleeyax
Copy link
Author

sleeyax commented Sep 24, 2023

It looks like I need to add a dependency to SLF4J and another logging library. I assumed kotlin-logging would be a simple standalone implementation but I guessed wrong. It's actually in the README but I skipped that section too fast.

@sleeyax sleeyax closed this as completed Sep 24, 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

1 participant