Reputation: 2577
I've setup (logger class constructor) logging as below-
Log() {
loggerObj = Logger.getLogger("");
//Create console handler and set its level and then setup its formatter
handler = new ConsoleHandler();
handler.setLevel(Level.FINEST);
formatter = new LogFormatter();
handler.setFormatter(formatter);
//assign handler to logger objs
loggerObj.setUseParentHandlers(false);
loggerObj.addHandler(handler);
}
Members of the Log class are-
static Logger loggerObj;
ConsoleHandler handler;
LogFormatter formatter;
Even though I've setup level to be FINEST and setUseParentHandlers to false, why is that I am not able to log anything below INFO?
EDIT- As per comment- After I modified the global logging.properties file and set level to ALL, it worked. So I think my question is why setUseParentHandlers isn't working?
Upvotes: 2
Views: 657
Reputation: 23886
As mentioned in the errata, setUseParentHandlers
specifies whether to send data recursively up the logging tree. Unless you explicitly don't want log messages to propagate to loggers that parent this one, that command shouldn't have any bearing on how they behave in the context of a single invocation.
Upvotes: 1
Reputation: 718906
So I think my question is why setUseParentHandlers isn't working?
There is no evidence that setUseParentHandlers
is NOT working.
Rather, what appears to be happening is that your Logger is (was) being created with the default level of INFO
. Try setting it by hand by calling Logger.setLevel(FINEST)
.
Upvotes: 2