Two questions about logging
K Richard Pixley
rich at noir.com
Thu Jan 12 20:03:59 EST 2012
On 1/11/12 18:19 , Matthew Pounsett wrote:
> Second, I'm trying to get a handle on how libraries are meant to
> integrate with the applications that use them. The naming advice in
> the advanced tutorial is to use __name__ to name loggers, and to allow
> log messages to pass back up to the using application's logger for
> processing, but these two pieces of advice seem contradictory.. since
> log messages only pass back up to the root if the loggers are named
Here's the confusion. Each log named __name__ is under the root logger.
If you want them all, then catch them all with the root logger.
In foo.py, change getLogger(__name__) to getLogger(''). Only the
included modules need __name__. Or use two - one logger for setting
handlers based on the root logger, and another based on __name__ for
logging from the top level.
More information about the Python-list