June 28, 2015

Logger Template Configuration in Eclipse

Steps:
1.Open Eclipse IDE-> Window -> Preferences->Java->Editor-> Templates
2. Click on New, give template name and description. Copy the corresponding pattern from below. Make sure Automatically Insert is checked.
3. Click on Ok, Apply and then Ok in the next window.


//logger method entry : logentry
if (logger.isDebugEnabled()) {
            logger.debug(Logger.METHODENTRY + " ${enclosing_method}");
        }
        

//logger method exit : logexit
if (logger.isDebugEnabled()) {
            logger.debug(Logger.METHODEXIT + " ${enclosing_method}");
        }
        
//logger error : logerror
logger.error("ERROR:${enclosing_type} : ${enclosing_method}" + e.getMessage(), e);

//logger  info : loginfo
logger.info("[${var}]:::::" + ${var});

Usage:
 To use these templates, please place the cursor where you want to insert the code and type the name of the template. After this, press CTRL+ SPACEBAR to insert the code automatically.

Ex: If you want to add logger.error, type logerror(i.e, template name) and press CTRL+ SPACEBAR

No comments:

Post a Comment

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts