如何在Ked中禁用日志

2024-03-28 20:20:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我没有成功地禁用kedro日志。我试着把disable_existing_loggers: True添加到日志.yml文件以及disable:True添加到所有现有日志中,它似乎仍在保存日志文件。有什么建议吗?你知道吗


Tags: 文件trueymlloggers建议disableexistingkedro
1条回答
网友
1楼 · 发布于 2024-03-28 20:20:46

如果希望kedro停止日志记录,可以根据documentation覆盖ProjectContext中的_setup_logging。例如:

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()

如果希望它仍然登录到控制台,但不保存到logs/info.log,那么可以执行def _setup_logging(self) -> None: pass。你知道吗

相关问题 更多 >