gpt4 book ai didi

python - 关闭 Snowflake DB 日志记录,同时仍将日志级别保持为 DEBUG

转载 作者:太空宇宙 更新时间:2023-11-04 04:09:49 24 4
gpt4 key购买 nike

是否可以禁用 Snowflake SQL 日志记录,它记录数据库连接的开始和结束以及所有正在执行的查询,同时保持 logging.basicConfig(level=logging.INFO) 用于调试我的发展。

也许这不是 Snowflake 特有的,而是来自 Python 的一般数据库连接?

我正在使用 snowflake-connector-python 1.8.1 版

我目前拥有的示例简化日志。

2019-06-10 16:27:10,015 INFO: /*Need this line*/

2019-06-10 16:27:10,015 INFO: Snowflake Connector for Python Version: 1.8.1, Python Version: 3.7.3, Platform: Windows-7-6.1.7601-SP1
2019-06-10 16:27:10,015 INFO: This connection is in OCSP Fail Open Mode. TLS Certificates would be checked for validity and revocation status. Any other Certificate Revocation related exceptions or OCSP Responder failures would be disregarded in favor of connectivity.
2019-06-10 16:27:10,020 INFO: Starting new HTTPS connection (1): xyz.snowflakecomputing.com
2019-06-10 16:27:11,227 INFO: query: [USE WAREHOUSE test_wh]
2019-06-10 16:27:11,481 INFO: query execution done
2019-06-10 16:27:11,481 INFO: query: [SELECT COLUMN_NAME FROM DB.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG =...]
2019-06-10 16:27:12,830 INFO: query execution done
2019-06-10 16:27:12,830 INFO: fetching data done
2019-06-10 16:27:12,830 INFO: closed
2019-06-10 16:27:13,185 INFO: /*Need this line*/
2019-06-10 16:27:13,581 INFO: /*Need this line*/
2019-06-10 16:27:14,604 INFO: /*Need this line*/

最佳答案

在导入 snowflake.connector 的 Python 模块中,在调用连接器上的任何方法之前,添加

logging.getLogger('snowflake.connector').setLevel(logging.WARNING)

让它只记录警告或更高级别。

关于python - 关闭 Snowflake DB 日志记录,同时仍将日志级别保持为 DEBUG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56525319/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com