Sanjeev’s Weblog

Mostly my techie notes, which could help any Java guy

Using java.util.logging

import java.util.logging.*;

Define a static variable in class of type import java.util.logging.Logger

final static Logger logger = Logger.getLogger(MyLoggingClass.class.getName());

Use logging as below

logger.log(Level.INFO,”getUserDetails | userID=”+userID);

The output will come like this on console

[3/11/08 13:58:41:531 SGT] 00000037 MyLoggingClas I getUserDetails | userID=webmaster

Note the name of class name is coming by itself because it was passed in getLogger() method. Different levels of logs like SEVER, FINER, INFO etc can be used depending upon the requirement.

March 11, 2008 Posted by urssanj00 | Java | , , | No Comments Yet