SLF4J Eclipse templates
I’m sure lot of Eclipse developers are happy with Log4E, but for those who does not have Log4E or do not like to “pollute” Eclipse with plugins, I wrote few templates for SLF4J logging.
Just open Preferences and navigate to Java>Editor>Templates

Eclipse Preferences
…and press Import… button. And import: slf4j-eclipe-templates (download this file first)
Hit OK.
Now in Java editor start to type “logge” (without the quotes) and press CTRL+Space…
After hitting enter…
Just as it should be. Imports set, logger created.
I have defined templates for logging to, for example “loginfo” will create a log info message, just like this:
Hit enter, and the output will be:
First the LOGGER will be selected, after one TAB you’ll be inside the LOGGER.info() function…
The summary of templates provided:
| logger | create a logger instance with imports |
| loginfo | create log entry of info level |
| logerror | create log entry of error level |
| logwarn | create log entry of warn level |
| logtrace | create log entry of trace level |
| logdebug | create log entry of debug level |
That’s it.
For Eclipse Editor Templates open Eclipse Help (Infocenter) and navigate to Java development user guide > Concepts > Templates




Hi. slf4j provides the {} construct which – properly used – delays the toString evaluation so the isEnabled check can happen inside slf4j. This means that “log.debug(“foo={}”, foo)” is very cheap if debug log is disabled, and the code gets cleaner.
@Thorbjørn That’s right. That is described under SLF4J FAQ: Performance.
I’ll add a new template XML in few days.
Thx for an advice!