Do you use eclipse and log4j? Do you have a template to add a static Logger instance in classes? Do you have to manually add the import? HA! NO MORE!
Under Preferences > Java > Editor > Templates, click New…
Give the template a name (like “logger”).
Use this for the Pattern:
${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);
Click OK, OK, then incant the template by typing the name of the template and invoke Content Assist (ctrl-space on most platforms).
The import line will add org.apache.log4j.Logger to your imports automatically if it doesn’t exist already. Nifty, eh?
Related posts:
- Simple spring integration testing
Spring has had a really nice unit test framework available for a while now, but the documentation can be a bit daunting. Here’s a super-simple example of adding dependency injection...... - IDEA versus Eclipse
IDEA has been giving me grief lately. Fed up with mysterious pauses, bugs in svn moves, and crashes even after performing cache-deletion voodoo in IDE, I’m back to trying Eclipse....... - How to increase maven heapspace in hudson builds
If your maven-built project fails in hudson (especially when you’re using the assembly plugin) and it isn’t a compile or test failure, check the console output. If it says “java.lang.OutOfMemoryError:...... - How to serve a transparent 1×1 pixel GIF from a servlet
The first issue was how to build the smallest possible byte array that represents a 1×1 GIF. Using ImageMagick piped to base64 made it easy to embed into java code:......