Eclipse IDE predefined variable for current class
Asked Answered
E

2

5

I have a logger defined for every Java class:

private XLogger logger = XLoggerFactory
        .getXLogger(AuthenticationFailureHandlerImpl.class.getName());

I want to add this to Eclipse snippets. Is there a pre-defined Eclipse variable such that the class name could be dynamically replaced with the class name where this snippet is inserted?

Thank you.

English answered 18/11, 2011 at 18:5 Comment(0)
A
7

I'm using this:

private static final Log LOG = LogFactory.getLog(${enclosing_type}.class);

Define it in Java->Editor->Templates of the Eclipse Preferences.

Ambrosius answered 22/5, 2012 at 14:15 Comment(0)
S
5

Additionally, you can add imports.

${imp:import(org.slf4j.Logger, org.slf4j.LoggerFactory)}
private static final Logger logger = LoggerFactory.getLogger(${enclosing_type}.class);
Seville answered 18/1, 2016 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.