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.

Advertisement

March 11, 2008 - Posted by | Java | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.