Mysterious Logging Handlers

dieter dieter at handshake.de
Sat Sep 10 04:35:24 EDT 2016


Josh English <Joshua.R.English at gmail.com> writes:
> I have a Python script that imports a utility script. Both scripts use logging, but the logs don't work as advertised. I'm getting logging output from the utility script but none from the main file. Worse, the format of the utility script's logs don't match anything I define.
>
> The utility script is called xlreader.py. It has the following lines:
>
> -- begin snippet --
> import logging
> XLOGGER = logging.getLogger('XLREADER')
> -- end snippet --
>
> And it calls XLOGGER.debug(), XLOGGER.error() and XLOGGER.info() but it never defines a handler.
> ...

Python's logging system is quite complex. Among others, it has a logger
hierarchy where loggers on a lower level can delegate to their parent.
Usually, most configuration happens at the so called "root logger"
and is used by all loggers which have not overridden certains aspects.

In your special case, the handlers likely come from the "root logger".




More information about the Python-list mailing list