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!