Logging

Annotate any class with a @Slf4j annotation to let lombok generate a logger field. The logger is named log.

@Slf4j

Creates:

private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);
1

Here is a complete example:

@Slf4j
public class LogExampleOther {
  
  public static void main(String... args) {
    log.error("Something else is wrong here");
  }
}
1
2
3
4
5
6
7

Reference (opens new window)