Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok @Log4j2 annotation doesn't work in IntelliJ IDEA [duplicate]

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")
}
like image 717
Orest Avatar asked Mar 16 '17 08:03

Orest


People also ask

What is Lombok IntelliJ?

Lombok is a library that facilitates many tedious tasks and reduces Java source code verbosity. Of course, we usually want to be able to use the library in an IDE, which requires additional setup. In this tutorial, we'll talk about configuring Lombok in two of the most popular Java IDEs — IntelliJ IDEA and Eclipse.


2 Answers

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.

like image 157
Chirrut Imwe Avatar answered Sep 23 '22 18:09

Chirrut Imwe


Just installing the lombok plugin for intellij works for me.

like image 23
surbasu Avatar answered Sep 22 '22 18:09

surbasu