Here is the Eclipse template that I want to port:
${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class)
Just to save a little time for new visitors here: the accepted answer now needs some changes.
Go to Settings -> Editor -> Live Templates
, select others
, add a template:
private static final org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger($CLASS_NAME$.class);$END$
Then, press Edit Variables
on the left and set expression for CLASS_NAME
to className()
.
After all, set context on the bottom to Java -> Declaration
(and Groovy -> Declaration
if desired).
Imports will be magically generated on insert.