Logging with multiple loggers/handlers
vinay_sajip at yahoo.co.uk
Fri Aug 6 11:08:14 CEST 2004
> Loggers are never instantiated directly. Instead, a module-level
> function is used:
> def getLogger(name=None): ...
> If no name is specified, the root logger is returned. Otherwise,
> if a logger with that name exists, it is returned. If not, a new
> logger is initialized and returned. Here, "name" is synonymous
> with "channel name".
> And the descriptions of the config file
> #The channel value indicates the lowest portion of the channel name
> of the
> #logger. For a logger called "a.b.c", this value would be "c".
> All of this combined to give me the impression that the name that's
> passed to getLogger() should be the "lowest portion" channel name,
> rather than the fully qualified name -- i.e., that I should be using
> "log03" instead of "log02.log03". As it turns out, my impression was
> wrong -- it's the fully qualified name that should be used.
> While it's fairly likely that my interpretation of the docs is not
> something that many people will come up with, I think it might be
> worthwhile to expand the example sections to actually show how to use
> multiple heirarchical loggers. Had there been an example to follow, I
> certainly wouldn't have made this mistake.
The example in http://www.red-dove.com/python_logging.html#config does
show in bold the items used by the configuration API, and says that
the others are just used by the GUI configurator. Perhaps "channel"
was the wrong name to use for a private element in the configurator,
but it's done now.
More information about the Python-list