Logger Inserts |
||
You can either insert logger statements for the whole class, for a certain method or at a certain position. These tasks are described in the following subsections. |
||
Inserts for method/class |
||
Two operations are executed: Most of the documentation is already done in the Preferences (see Statements and Positions). Here's an example:
Before: public String myMethod(String theString, int theInt) { //Your code.... try { doSomethingVeryDangerous(); } catch (Exception myexception) { return null; } return toString(); }
After: public String myMethod(String theString, int theInt) { if (logger.isDebugEnabled()) { logger.debug( "myMethod(String theString = " + theString + ", int theInt = " + theInt + ") - start"); } //Your code.... try { doSomethingVeryDangerous(); } catch (Exception myexception) { logger.error("myMethod()", myexception); if (logger.isDebugEnabled()) { logger.debug("myMethod() - end"); } return null; } String returnString = toString(); if (logger.isDebugEnabled()) { logger.debug("myMethod() - end"); } return returnString; } Note that Log4E checks if "returnString" already exists and appends a number. e.g. if "returnString" exists the new variable would be "returnString2" (and so on). |
||
Insert at certain position |
||
Place the textcursor at a valid position within a method and invoke the submenu "Log4E->Insert Log Statement At This Position...". A Wizard pops up as shown below. Wizard settings:
There's a preview afterwards:
|
||
|