当前位置:主页 > >

Django日志及中间件模块应用案例

时间:2020-09-10 17:00:18 | 栏目: | 点击:

基于邮件通知的服务监控和告警系统

主要功能点:

配置专用日志格式记录耗时

日志格式:

'simple':{
	'format':'%(asctimme)s %(message)s'
}

处理器

'statistics_handler':{
	'level':'DEBUG',
     'class':'logging.handlers.RotatingFileHandler',
      'filename':os.path.join(LOG_DIR,'backend.log')
     'maxBytes':'1024*1024*1024' # class参数如果日志大小超了会新建文件
     'backupCount':5 #备份数
     'formatter':'simple',
      'encoding':'utf-8'
}

日志实例

'statistics':{
	'handlers':['statistics_handler'],
	'level':'DEBUG'
}


编写请求耗时统计功能的中间件

获取日志实例

分析日志的任务函数业务逻辑文件

您可能感兴趣的文章:

相关文章