Issue
I have a Kotlin Gradle project. I added Lombok as a dependency and also registered it with kapt
compileOnly("org.projectlombok:lombok:$lombokVersion")
kapt("org.projectlombok:lombok:$lombokVersion")
I would like to use the href="https://projectlombok.org/api/lombok/extern/slf4j/Slf4j.html" rel="nofollow noreferrer">@Slf4j
annotation for automatic logger generation. It works for Java classes but not for the Kotlin ones.
Is using Kotlin and Lombok together even possible as of now? If I annotate a Kotlin class with @Slf4j
and use log
inside it I get
Unresolved reference: log
Evidently no annotation processing is applied.
Solution
You cannot use annotation @Slf4j
, but manually create its object in the class required.
Refer https://www.reddit.com/r/Kotlin/comments/8gbiul/slf4j_loggers_in_3_ways/
Answered By - Sahil Chhabra
Answer Checked By - David Marino (JavaFixing Volunteer)