如何将Azure诊断与Python一起使用?
我使用Visual Studio 2013创建了一个python项目(控制台应用程序),并安装了以下软件: 1) Microsoft Azure SDK for Python 3.4- 2) Visual Studio的Python工具- 我成功地使用Python访问了Azure存储(Blob&Queue)。但是,我无法使用Azure Diagnostics记录消息如何将Azure诊断与Python一起使用?,python,visual-studio-2013,azure-diagnostics,Python,Visual Studio 2013,Azure Diagnostics,我使用Visual Studio 2013创建了一个python项目(控制台应用程序),并安装了以下软件: 1) Microsoft Azure SDK for Python 3.4- 2) Visual Studio的Python工具- 我成功地使用Python访问了Azure存储(Blob&Queue)。但是,我无法使用Azure Diagnostics记录消息 有没有一种方法可以将Azure Diagnostics与Python源代码一起使用?Azure Diagnostics可以收集以下
有没有一种方法可以将Azure Diagnostics与Python源代码一起使用?Azure Diagnostics可以收集以下类型的遥测数据:
- IIS日志
- Azure诊断基础架构日志
- IIS失败的请求日志
- Windows事件日志
- 性能计数器
- 崩溃转储
- 自定义错误日志
- .NET事件源
- 基于舱单的ETW
LOGGING = {
'version': 1,
'formatters': {
'simple': {
'format': '%(asctime)s %(message)s',
},
'verbose': {
'format': '%(asctime)s %(levelname)s %(hostname)s %(process)d %(message)s',
},
# this is the same as the default, so you can skip configuring it
'partition_key': {
'format': '%(asctime)s',
'datefmt': '%Y%m%d%H%M',
},
# this is the same as the default, so you can skip configuring it
'row_key': {
'format': '%(asctime)s%(msecs)03d-%(hostname)s-%(process)d-%(rowno)02d',
'datefmt': '%Y%m%d%H%M%S',
},
},
'handlers': {
'file': {
'account_name': 'mystorageaccountname',
'account_key': 'mystorageaccountkey',
'protocol': 'https',
'level': 'DEBUG',
'class': 'azure_storage_logging.handlers.BlobStorageTimedRotatingFileHandler',
'formatter': 'verbose',
'filename': 'example.log',
'when': 'D',
'interval': 1,
'container': 'logs-%(hostname)s',
'zip_compression': False,
},
'queue': {
'account_name': 'mystorageaccountname',
'account_key': 'mystorageaccountkey',
'protocol': 'https',
'queue': 'logs',
'level': 'CRITICAL',
'class': 'azure_storage_logging.handlers.QueueStorageHandler',
'formatter': 'verbose',
},
'table': {
'account_name': 'mystorageaccountname',
'account_key': 'mystorageaccountkey',
'protocol': 'https',
'table': 'logs',
'level': 'INFO',
'class': 'azure_storage_logging.handlers.TableStorageHandler',
'formatter': 'simple',
'batch_size': 20,
'extra_properties': ['%(hostname)s', '%(levelname)s'],
'partition_key_formatter': 'cfg://formatters.partition_key',
'row_key_formatter': 'cfg://formatters.row_key',
},
},
'loggers': {
'example': {
'handlers': ['file', 'queue', 'table'],
'level': 'DEBUG',
},
}
}
import logging
from logging.config import dictConfig
dictConfig(LOGGING)
logger = logging.getLogger('example')
logger.debug('debug message')
logger.info('info message')
logger.warning('warning message')
logger.error('error message')
logger.critical('critical message')