I assumed with this configuration that we were indeed configuring and using the true root logger. However, this is giving a logger named "root", but not the true root logger I believe. When I use this configuration logged statements from other imported libraries aren't propagated up to this logger. So the problem I encountered was not being able to handle correctly logging statements from other imported libraries.
logging_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"minimal": {"format": "%(message)s"},
"detailed": {
"format": "%(levelname)s %(asctime)s [%(name)s:%(filename)s:%(funcName)s:%(lineno)d]\n%(message)s\n"
},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"stream": sys.stdout,
"formatter": "minimal",
"level": logging.DEBUG,
},
"info": {
"class": "logging.handlers.RotatingFileHandler",
"filename": Path(LOGS_DIR, "info.log"),
"maxBytes": 10485760, # 1 MB
"backupCount": 10,
"formatter": "detailed",
"level": logging.INFO,
},
"error": {
"class": "logging.handlers.RotatingFileHandler",
"filename": Path(LOGS_DIR, "error.log"),
"maxBytes": 10485760, # 1 MB
"backupCount": 10,
"formatter": "detailed",
"level": logging.ERROR,
},
},
"root": {"handlers": ["console", "info", "error"], "level": logging.INFO, "propagate": True},
}
logging.config.dictConfig(logging_config)
# Obtains the root logger; all child logging will propagate up to root logger
logger = logging.getLogger()