Eclipse SLF4J Editor Templates

For all but the most trivial cases, a set of well placed and meaningful log messages are essential for maintenance and debugging purposes.

So far, I have found SLF4J & Logback to be the best solution for classic as well as OSGi based Java applications.

To simplify the addition of loggers into code, i use a customized version of the Eclipse IDE Java editor templates provided by Ceki Gülcü:

Download the Eclipse SLF4J Editor Templates.

Simply unzip and import the templates via the Java -> Editor -> Templates preferences page in the Eclipse IDE.

EclipseSLF4JEditorTemplatesScreenshot

Afterwards, type “sloc” or “ilog” and push Strg-Space to expand the template. “sloc” will add a static final Logger, “ilog” will put the Logger in an instance variable. The pros and cons of both methods are described here.

Add Comment

Required fields are marked *. Your email address will not be published.