Trouble propagating logging configuration

Dieter Maurer dieter at handshake.de
Tue Aug 31 13:01:53 EDT 2021


Loris Bennett wrote at 2021-8-31 15:25 +0200:
>I am having difficulty getting the my logging configuration passed on
>to imported modules.
>
>My initial structure was as follows:
>
>  $ tree blorp/
>  blorp/
>  |-- blorp
>  |   |-- __init__.py
>  |   |-- bar.py
>  |   |-- foo.py
>  |   `-- main.py
>  `-- pyproject.toml
>
>whereby the logging configuration is done in main.py.
>
>After thinking about it, I decided maybe the inheritance wasn't working
>because main.py is in the same directory as the other files.

Should you speak about Python's `logging` module, then
the "inheritance" does not depend on the source layout.
Instead, it is based on the hierarchy of dotted names.
It is completely up to you which dotted names you are using
in your `getLogger` calls.

Furthermore, the place of the configuration (and where in the
code it is activated) is completely irrelevant for the "inheritance".

For details, read the Python documentation for the `logging` module.


More information about the Python-list mailing list