SLF4J Code Template for Netbeans

by 4/24/2007 09:32:00 AM 4 comments

SLF4J Code Template for Netbeans

I use Netbeans alot for Java development. I also used Loggers a great deal and Netbeans Code Template feature is a quick an easy way to insert this boiler plate code. Here's an example code template for inserting the code for creating an SLF4J logger [Note I've wrapped it in this blog, but it should all be on one line]:
private static final 
   ${LOG_TYPE type="org.slf4j.Logger" default="Logger" editable=false} 
   log = ${LOG_FACT type="org.slf4j.LoggerFactory" 
   default="LoggerFactory" editable=false}.getLogger(${CLASS});
I've added this tip to Netbeans Community Docs at

Brian Schlining


Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.


Ceki said...

Cool. I be sure to reference your blog with the next release of SLF4J.

James said...

My name is James Branam and I'm the NetBeans Community Docs Manager. Your blog entry would make a fantastic tutorials for our Community Docs wiki ( Would you be willing to contribute it? If you need any help or have any questions, please contact me at I look forward to hearing from you.

Xanthros said...

I would point you to the SLF4J FAQ on using *static* for your template.

It asks the question: "Should Logger members of a class be declared as static?"

Before I read this I never considered this possibility and found the read to be very informative as I hope you and your readers do too.

Hohonuuli said...


Thanks for pointing that out, it's an interesting read and makes a good case for using local instances of loggers on JEE app servers.

In my case, I generally don't write too many server apps in Java these days, I actually use it for desktop applications or services. In these cases, static logger instances seem more appropriate.