Monday, June 4, 2012

Eclipse Java Template for Apache Commons Logging

If you use Eclipse and want to save some typing, here is a template for Eclipse to generate an Apache Commons Logging Log for the class you are currently working on.


${:import(org.apache.commons.logging.Log,org.apache.commons.logging.LogFactory)}
private static final Log LOG = LogFactory.getLog(${primary_type_name}.class);


To use it, open preferences > java > editor > templates, create a new template with the name "log" and paste the code above in the Pattern field.

Eclipse Slf4j Logger Template

If you use eclipse and want to save some typing, here is a template for Eclipse to generate an Slf4j Logger for the class you are currently working on.

    ${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)}
        private static final Logger LOG = LoggerFactory.getLogger(${primary_type_name}.class);

To use it, open preferences > java > editor > templates, create a new template with the name "log" and paste the code above in the Pattern field.