是否可以禁用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*/
答案 0 :(得分:1)
我发现@john Velonis的解决方案不能完全消除所有雪花消息。我仍然收到这样的消息:
2020-03-26 18:03:04 DEBUG: network._request_exec:805 - SUCCESS
2020-03-26 18:03:04 DEBUG: network._use_requests_session:944 - Active requests sessions: 0, idle: 1
2020-03-26 18:03:04 DEBUG: network._post_request:533 - ret[code] = None, after post request
2020-03-26 18:03:04 DEBUG: cursor.execute:543 - sfqid: 0193261b-0310-8c37-0003-c9033ae3696a
2020-03-26 18:03:04 INFO: cursor.execute:545 - query execution done
2020-03-26 18:03:04 DEBUG: cursor.execute:547 - SUCCESS
2020-03-26 18:03:04 DEBUG: cursor.execute:551 - PUT OR GET: None
2020-03-26 18:03:04 DEBUG: cursor._init_result_and_meta:611 - Query result format: arrow
2020-03-26 18:03:04 DEBUG: cursor._init_result_and_meta:631 - Batches read: 8
2020-03-26 18:03:04 DEBUG: cursor.fetchone:824 - Arrow BatchSize: 8
2020-03-26 18:03:04 DEBUG: cursor.fetchone:824 - Arrow chunk info: batchCount 8, columnCount 8, use_numpy: 0
2020-03-26 18:03:04 DEBUG: cursor.fetchone:824 - Current batch index: 0, rows in current batch: 48
2020-03-26 18:03:04 DEBUG: cursor.fetchone:824 - Current batch index: 1, rows in current batch: 52
2020-03-26 18:03:04 DEBUG: cursor.fetchone:824 - Current batch index
我认为这些来自某些CPP code here。为了使它们静音,我还必须将snowflake.connector.CArrowIterator
设置为更高的日志级别。我使用了这样的代码:
import logging
for name in logging.Logger.manager.loggerDict.keys():
if 'snowflake' in name:
logging.getLogger(name).setLevel(logging.WARNING)
logging.getLogger(name).propagate = False
答案 1 :(得分:0)
在导入snowflake.connector
的Python模块中,在连接器上调用任何方法之前,添加
logging.getLogger('snowflake.connector').setLevel(logging.WARNING)
使其仅记录警告或更高级别。
答案 2 :(得分:0)
尝试
logging.getLogger('snowflake.connector.connection').propagate=False