I think I've tried just about any combination and I keep hitting the wall with regards to logging. I've been trying to get my head around the Logging cookbook and various posts mentioning the same issue, but I just don4t get it. My code is fairly simple:
Main module (main.py):
#my modules
import manager
import metadata
import logging
import logging.config
if config_file:
logging.config.fileConfig(config_file)
else:
logging.basicConfig(level=logging.INFO)
Then in both modules (manager.py and metadata.py) that are imported in the main.py module:
import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
Finally, the logger config file:
[loggers]
keys=root, manager, metadata
[logger_root]
level=NOTSET
handlers=console
qualname=root
[logger_manager]
level=DEBUG
handlers=console
qualname=manager
[logger_metadata]
level=DEBUG
handlers=console
qualname=metadata
If I now run the main.py, I will end up with only logging for root.
On the other hand, if I change my code as follows:
manager.py:
import logging
logger = logging.getLogger('manager')
logger.addHandler(logging.NullHandler())
metadata.py:
import logging
logger = logging.getLogger('metadata')
logger.addHandler(logging.NullHandler())
I'll get duplicate logging for manager and metadata.
Any hints would be greatly appreciated.