I have been trying to get the Java logger to work,...
# getting-started
r
I have been trying to get the Java logger to work, but it keeps saying the reference to LoggerFactory is unresolved. Should I replace it with something else, or is it my project setup?
Copy code
companion object { 
        private val log = LoggerFactory.getLogger(MyClass::class) // TODO
s
My guess is that it's a setup issue, but I don't know
c
You probably need to pass the Java class, not the KClass:
Copy code
companion object {
        private val log = LoggerFactory.getLogger(MyClass::class.java) // TODO
s
Also if you're feeling adventurous and want a possibly easier setup, I set up one of my side projects with kotlin logging which is a wrapper around slf4j I think https://github.com/MicroUtils/kotlin-logging
r
@Casey Brooks Maybe too, but still the
Unresolved reference: LoggerFactory
error is something else I think
@Steven McLaughlin I will try, once I've got everything up and running 😉 I got some files to go to migrate
👍 1
I have this in my graddle:
Copy code
sourceSets {
        commonMain {
            dependencies {
                // ... some more
                implementation 'org.slf4j:slf4j-api:1.8.0-beta2'
Is that correct?
It shows up under the 'External Libraries' in my IDE. Though it still cannot import or resolve 😞
m
You need to provide an implementation for the logging too. slf4j-api is just that. Only the API. A popular JVM logger is logback.
r
I see, thank you 👍