I am trying to use lombok's @Slf4j annotation. It works fine for non-static methods but I am unable to use them for static ones, e.g.:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MyClass {
public static void staticMethod() {
log.info(""); //build error
//code
}
public void nonStaticMethod() {
log.info(""); //builds ok
//code
}
More specifically the build error is:
Error:(17, 9) java: non-static variable log cannot be referenced from a static context
So either I am missing something or this simply is not the way to do it, but what is causing me some confusion is that other answers seem to indicate that this usage is the correct one. Does anyone know what am I doing wrong? Thank you for your help.