简体   繁体   English

使用structlog登录Python项目,并记录需要删除的第三方库

[英]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.

相关问题 Python - 使用 structlog 从多个模块记录日志 - Python - Logging from multiple modules using structlog 在项目中列出第三方库 - Listing third party libraries in project 如何使用c#.net运行包含第三方库的python脚本? - how to run python script which contains third party libraries using c#.Net? 上传Python第三方库 - Uploading Python third party libraries 使用没有第三方库的Python反转已知算法 - Reverse a known algorithm in Python using no third party libraries 使用第三方库时带有“gbk”的 Python UnicodeDecodeError - Python UnicodeDecodeError with 'gbk' while using third party libraries 是否可以在python中不使用第三方库的情况下抓取网页? - Is it possible to scrape webpage without using third-party libraries in python? 无法使用日志记录控制 structlog - Unable to control structlog using logging 使用第三方库进行Python部署 - Python deployment with third-party libraries 将第三方库与python项目捆绑在一起的最佳做法是什么? (对于没有互联网的用户) - What is the best practice for bundling third party libraries with your python project? (for users with no Internet)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM