Thursday, October 16, 2008

How to use Java Logger

1. Define the LOGGER instance for the class
private static final String CLASSNAME = WASUtil.class.getName();
private static final java.util.logging.Logger LOGGER =
java.util.logging.Logger.getLogger(CLASSNAME);
2. Log trace on your specified level
LOGGER.log(Level.FINE, "profile name: "+name);

3. Enable the trace to a benchmark level. For example, for a standalone program,
you can enable trace by modifying /lib/logging.properties,
java.util.logging.ConsoleHandler.level = ALL
com.yourcompany.yourclass.level=FINER
will trace all the entries with trace level higher than FINER, ie, FINE, CONFIG, INFO.

No comments:

Post a Comment