@Log

Overview

You can annotate any field with @Log to let lombok generate a logger field automatically.
The logger is named log and field's type depends on which logger you have selected.

There are four @Log choices available:

@lombok.extern.apachecommons.Log
Creates private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LogExample.class);
@lombok.extern.jul.Log
Creates private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LogExample.class.getName());
@lombok.extern.log4j.Log
Creates private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LogExample.class);
@lombok.extern.slf4j.Log
Creates private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(LogExample.class);

All @Log annotations can take an optional parameter of type Class. If such a parameter is specified, that class will be used as the parameter for the logger factory call.

With Lombok

@HTML_PRE@

Vanilla Java

@HTML_POST@

Small print

If a field called log already exists, a warning will be emitted and no code will be generated.

Although it is possible to specify any class literal to pass to the logger factory method, passing void.class will be considered to be the same as specifying no parameter.