I have a Python library that has an internal Logger
, something like this:
library_logger = logging.getLogger("library.submodule")
I have a lightweight wrapper class of the library that has it's own Logger
:
wrapper_logger = logging.getLogger("my_package.library_wrapper")
I would like to one-way link the wrapper's logger to the library's logger such that:
LogRecords
from the library go through the wrapper'sHandler
s (e.g.FileHandler
), but not vice versa- Any changes to the wrapper's log level get propagated to the library's log level, but not vice versa
How can this be done?
Other Answers
- Logging hierarchy vs. root logger? talks about hierarchy of logging names, note they are in different hierarchies.
- Is it possible to combine two Python loggers? received no meaningful answers.