A logging.config.dictConfig() issue in python

logging.config.dictConfig()
python
Author

noklam

Published

June 20, 2021

import logging
from clearml import Task
conf_logging = {"version":1, 
                "formatters":{
                      "simple":{
                             "format":"%(asctime)s - %(name)s - %(levelname)s - %(message)s"}
                      }
                  }
t = Task.init(project_name="test")
logging.config.dictConfig(conf_logging)
logging.info("INFO!")
logging.debug("DEBUG!")
logging.warning("WARN!")
print("PRINT!")

With this code block, you will find no print() or logging is sent to ClearML logging Console. Turns out kedro use logging.config.dictConfig(conf_logging) as the default and causing this issue.

A quick fix is to add "incremental": True in the config dict. In the standard documentation, the default is False, which means the configuration will replace existing one, thus removing the clearml handlers, and causing the issue I had.

conf_logging = {"version":1, 
                "incremental": True
                "formatters":{
                      "simple":{
                             "format":"%(asctime)s - %(name)s - %(levelname)s - %(message)s"}
                      }
                  }