【发布时间】:2020-05-05 07:02:02
【问题描述】:
我正在尝试将错误记录到 azure blob,但它没有在 blob 中创建任何表。我浏览了很多文档,也在stackoverflow中搜索了ans。请帮我解决一下这个。 谢谢
下面是代码
定义日志():
import logging
import sys
from azure_storage_logging.handlers import BlobStorageRotatingFileHandler
mystorageaccountname='***'
mystorageaccountkey='***'
_LOGFILE_TMPDIR = mkdtemp()
logger = logging.getLogger('service_logger')
logger.setLevel(logging.DEBUG)
log_formater = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(message)s')
azure_blob_handler = TableStorageHandler(account_name=mystorageaccountname,
account_key=mystorageaccountkey,
protocol='https',
table='logtable',
batchsize=100,
extra_properties=None,
partition_key_formatter=None,
row_key_formatter=None,
is_emulated=False)
logger.addHandler(azure_blob_handler)
logger.warning('warning message')
【问题讨论】:
-
基于此链接:github.com/michiya/azure-storage-logging 并且根据您的代码,您的日志记录数据应该在您使用 TableStorageHandler 时进入 Azure 表存储。请检查表而不是 blob 容器。
-
它也没有创建任何表。我也尝试使用 BlobStorageRotatingFileHandler 创建一个文件,但我看不到任何文件。
标签: azure-storage azure-blob-storage azure-databricks python-logging