Lombok @Log4j2 annotation doesn't work in IntelliJ IDEA

13,659

Solution 1

So I had the same problem, I think. What I did is I installed the Lombok plugin in IntelliJ, enabled the annotation as in the link under Preferences-> Build, Execution, Deployment > Compiler > Annotation Processors. And then I restarted IntelliJ, and it worked. IDE is able to recognize log.

I tried it for log4j, log4j2 and slf4j. It all worked.

Let me know if this helped.

Solution 2

Just installing the lombok plugin for intellij works for me.

Share:
13,659

Related videos on Youtube

Orest
Author by

Orest

5+ years of experience mostly in backend applications

Updated on October 10, 2022

Comments

  • Orest
    Orest about 1 year

    I'm using Lombok library in my project and have a problem with @Log4j2 annotation. Not sure why but it's not generating log field in the class.

    But when I'm changing annotation to @Slf4j it works, I can see it in IntelliJ IDEA 'Structure' tab.

    I'm using gradle as a build tool. Have few dependencies"

    dependencies {
        compileOnly("org.projectlombok:lombok")
        compile("org.springframework.boot:spring-boot-starter-log4j2")
    }
    
    • Roel Spilker
      Roel Spilker over 6 years
      It could be that the IDEA plug-in doesn't support @Log4j2 yet. If that's the case IDEA will show an error message, but compiling the code should work.
  • rahulmohan
    rahulmohan about 3 years
    I am on IntelliJ Idea 2020.2 Mac Version with lombok plugin 0.32-2020.2. In addition to the above answer I also had to turn on log annotation in lombok plugin settings (Preferences > Other Settings > Lombok Plugin > Enable @Log support)