|
-
Java logging API
Hi,
I have been reading one of the tutorials on this website entitled, "Looking into the JDK 1.4 Logging API".
http://javaboutique.internet.com/tut.../logging2.html
I found the tutorial to be very helpful and easy to follow, but I am having difficulty in re-creating the example relating to The Logger Hierarchy:
Specifically, I have two classes, which I have placed in the same package:
package test;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
public class LoggingConfigClass {
public static void main(String[] args) {
Logger logger = Logger.getLogger("test");
logger.setLevel(Level.FINEST);
ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINEST);
logger.addHandler(consoleHandler);
logger.setUseParentHandlers(false);
// handler configured to Level.FINEST - both log messages displayed
logger.info("INFO level log message");
logger.finest("FINEST level log message");
}
}
package test;
import java.util.logging.Logger;
public class LoggingTestClass {
private static Logger logger = Logger.getLogger("test.LoggingTestClass");
public static void main(String[] args) {
// expecting to see BOTH log messages displayed because of config in LoggingConfigClass
// only INFO log message gets displayed...why is this?
logger.info("INFO level log message");
logger.finest("FINEST level log message");
}
}
The LoggingConfigClass, as the name suggests, configures a logger and displays two messages. This class works as I anticipated.
The LoggingTestClass has a logger, which has no explicit configuration. I want to take advantage of the logger hierarchy (it should behave in the same way as the logger in LoggingConfig class). This does not happen despite the fact that I have been careful about how I named the logger in each class (which I think is the deciding factor in using logging hieriarchy???).
Could somebody please point out where I have gone wrong...?
THANKS!
Similar Threads
-
By RikMeucci in forum Java
Replies: 2
Last Post: 12-05-2005, 06:59 AM
-
By Glen Kunene in forum Talk to the Editors
Replies: 17
Last Post: 03-23-2002, 12:43 AM
-
By Dharmesh in forum .NET
Replies: 4
Last Post: 10-01-2001, 03:47 PM
-
By Andrew Shaw in forum VB Classic
Replies: 6
Last Post: 08-24-2000, 08:31 PM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks