My standard way of using Java Logging.
Level.SEVERE = All fatal exceptions - always seen
Level.WARNING = Default shown warnings
Level.INFO = General app info messages
** DEFAULT LEVEL IS INFO **
Level.CONFIG = Non error messages
Level.FINE = ??
Level.FINER = ??
Level.FINEST,"FINEST = Single bug fix
Class head
-
private static final Logger log = Logger.getLogger(ClassName.class.getName());
First line of class constructor
-
//LOGUtilities.SetLocalLogging(log, Level.ALL);
This line is commented out so when I am debuging I can put it back in if required
Main Methods
At the start of the program enter the following. The level in the info statement sets the global level.
-
LOGUtilities.init(Level.INFO); //Setup default log formatter
-
log.log(Level.INFO,"Starting Test");
-
-
//APP CODE
-
-
log.log(Level.INFO,"Ending Test");
Exception methods
-
log.log(Level.SEVERE,e.toString(),e);
-
}
No stack trace output needed as it will go into the log
RJM Article Type
Quick Reference