This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Java Util Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Util Logging" Watch "Java Util Logging" New topic

Java Util Logging

Srinivas Raghu

Joined: Jul 09, 2007
Posts: 8
Hi all,

i am using java util logging. in that i need to know abt

Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

You will use isLoggable() to avoid calling heavy logging process, which could have an impact on performance. For example, looping through a List and logging its content. You want to do it only if the logging level is lower than the level you are using.
Logger logger = Logger.getLogger("com.mycompany.MyClass");
if (logger.isLoggable(Level.FINEST)) {
for ( int i = 0; i < biglist.size(); i++ ) {
// loop through the list and do some other logging stuff. May take a few minutes

You don't need to use isLoggable() if the logging does not impact on performance. So in your case logger.finest("count: "+count); is ok.
You will have to set the logging level in a property file, which will determine of the "count" will be logged or not.

[My Blog]
All roads lead to JavaRanch
Srinivas Raghu

Joined: Jul 09, 2007
Posts: 8
Thank You for Your Reply
Srinivas Raghu

Joined: Jul 09, 2007
Posts: 8
I need to configure like log4j using util.logging.

For that, reading the file for my own application
usage (copied from jre/lib ). i need how to code for reading from that
file. "readConfigure" example i need.

also i need how to create -> currentdate.log file for each day

Thank You.
It is sorta covered in the JavaRanch Style Guide.
subject: Java Util Logging
Similar Threads
problem with java logging
Strange behaviour of MDB and EJB
Java logging API
Removing loggers from logger hierarchy in java util logging