Search code examples
pythonkedro

How to disable logs in Kedro


I have been unsuccessful in disabling kedro logs. I have tried adding disable_existing_loggers: True to the logging.yml file as well as disable:True to all of the existing logs and it still appears to be saving log files. Any suggestions?


Solution

  • If you want kedro to stop logging you can override the _setup_logging in ProjectContext in src/<package-name>/run.py as per the documentation. For example:

    class ProjectContext(KedroContext):
        """Users can override the remaining methods from the parent class here, or create new ones
        (e.g. as required by plugins)
    
        """
    
        project_name = "<PACKGE-NAME>"
        project_version = "0.15.4"
    
        def _get_pipelines(self) -> Dict[str, Pipeline]:
            return create_pipelines()
    
        def _setup_logging(self) -> None:
            import logging
            logging.disable()
    

    If you want it to still log to the console, but not save to logs/info.log then you can do def _setup_logging(self) -> None: pass.