[英]Logging in Python project using structlog and it logs third party libraries which needs to be removed
I am using structlog library to log for my Python project. 我正在使用structlog库记录我的Python项目。 I see some third party library logs which I do not want. 我看到一些不需要的第三方库日志。 How do I remove those logs? 如何删除这些日志?
Logging has a number of locations where you can filter messages. 日志记录具有许多可以过滤消息的位置。 Via the log level of the specific module as in logging.getLogger(...).setLevel(...)
or via a filter attached to a logger or attached to a handler. 通过特定模块的日志级别(如logging.getLogger(...).setLevel(...)
或通过附加到记录器或附加到处理程序的过滤器。
I solved this by adding the following in my logging setup: 我通过在日志记录设置中添加以下内容来解决此问题:
logging.config.dictConfig({
'disable_existing_loggers': True, # this disables the existing loggers from logging anything.
...
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.