Prev: Free Online Subversion Training - Introduction to Subversion for Developers
Next: Applet, file & resource
From: markspace on 30 Apr 2010 18:20 Rhino wrote: > Writing directly to the parent logger was only an experiment to > understand the problem. It seems to me that if the child logger is > supposed to pass up only qualifying messages to the parent logger, > then an application should never write directly to the parent logger. > > The other thing that baffles me is the Filter. Despite having put the > filter on both the parent logger (via the code) and the FileHandler > for the parent logger (via the logging.properties file), it doesn't > actually seem to do very much; it is certainly _not_ keeping FINEST Well, when in doubt, use the Force: read the source. Here's the code for the Logger's log(LogRecord) method: // Post the LogRecord to all our Handlers, and then to // our parents' handlers, all the way up the tree. Logger logger = this; while (logger != null) { Handler targets[] = logger.getHandlers(); if (targets != null) { for (int i = 0; i < targets.length; i++) { targets[i].publish(record); } } if (!logger.getUseParentHandlers()) { break; } logger = logger.getParent(); } So the first thing that happens (not shown) is that current logger's log level is checked. Only if the log record's level is less than the loggers do we fall into this loop above. Then this loop gets all of the handlers, and invokes each one. Then if useParentHandlers is true, it gets the handlers from the parent, and repeats. Note it DOES NOT CHECK THE PARENT'S LEVEL. If the current level was ok, then only the levels on the parent's handlers are checked, not the parent logger. This might explain the behavior you are seeing. Likewise, the parent's filters are skipped (the filter was also checked previously, only for this logger). Summary: 1. Parent handlers are ALWAYS invoked, if useParentHandlers is true. 2. Parent logLevel is NEVER checked, nor parent's the filters. Presumably, filters set on the handlers are always invoked, but I didn't verify that.
First
|
Prev
|
Pages: 1 2 Prev: Free Online Subversion Training - Introduction to Subversion for Developers Next: Applet, file & resource |