【发布时间】:2022-01-21 14:32:41
【问题描述】:
如何从 Databricks Notebook 代码中捕获日志并将其存储到 Azure 数据湖 gen 2 中的文件中?
我想为我的 Scala 语言代码实现自定义日志。
【问题讨论】:
-
这与 Scala 有什么关系?你刚才在这里问的不是问题。这是一个写书的请求。
标签: scala logging log4j databricks azure-databricks
如何从 Databricks Notebook 代码中捕获日志并将其存储到 Azure 数据湖 gen 2 中的文件中?
我想为我的 Scala 语言代码实现自定义日志。
【问题讨论】:
标签: scala logging log4j databricks azure-databricks
您可以使用 Python azure-storage-logging 库。
azure-storage-logging 提供从 Microsoft Azure 存储的标准 Python 日志记录 API。
import logging
from azure_storage_logging.handlers import TableStorageHandler
# configure the handler and add it to the logger
logger = logging.getLogger('example')
handler = TableStorageHandler(account_name='mystorageaccountname',
account_key='mystorageaccountkey',
extra_properties=('%(hostname)s',
'%(levelname)s'))
logger.addHandler(handler)
# output log messages
logger.info('info message')
logger.warning('warning message')
logger.error('error message')
【讨论】: