禁用特定代码行的日志记录

disable logging for specific lines of code

我正在调整 word2vec 模型超参数。 Word2Vec 有很多登录控制台,我无法读取 Optuna 或我的自定义日志。有什么技巧可以抑制 Word2Vec 生成的日志吗?

Gensim 的 classes 通常只有在您通过设置全局或 module/class-specific 日志记录级别在您的代码中专门打开它时才会记录。

那么,您确定没有打开更多您想要的日志记录吗?

在您的代码中搜索任何设置 INFODEBUG 日志记录级别的内容 - 删除该行或 adjust/narrow 该行不启用,或设置更严格的限制级别,在 word2vec 模块或 Word2Vec class.

我在 python 3.7 中使用了以下代码 python 3.6 我们已经发送 logging.ERROR 来禁用功能。

import logging

logging.disable()
#your code
logging.disable(logging.DEBUG)