Django日志及中间件模块应用案例
作者:Jimmyhe 时间:2021-06-02 22:16:50
基于邮件通知的服务监控和告警系统
主要功能点:
配置专用日志格式记录耗时
日志格式:
'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'
}
编写请求耗时统计功能的中间件
获取日志实例
业务逻辑功能编写
request时间,路径,response时间
配置定时任务统计指标并通过邮件发送
分析日志的任务函数业务逻辑文件
请求时间的最大值,最小值,平均值
邮件发送的配置
配置django-crontab
来源:https://www.cnblogs.com/jimmyhe/p/11185225.html
标签:Django,日志,中间件,模块
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
django中的auth模块与admin后台管理方法
2022-11-22 00:01:21
![](https://img.aspxhome.com/file/2023/4/102754_0s.png)
ASP.NET教程第二讲 ASP.NET学习
2007-08-07 12:01:00
SQL注入防御:用三种策略应对SQL注入攻击
2008-12-15 16:31:00
Python 内置函数complex详解
2022-02-16 03:57:41
Z-Blog垃圾留言判定新方法
2009-07-06 13:04:00
python3+PyQt5 使用三种不同的简便项窗口部件显示数据的方法
2021-10-25 12:14:57
![](https://img.aspxhome.com/file/2023/9/102729_0s.jpg)
什么是Dynamic HTML(Dhtml)
2010-03-16 12:40:00
python实现提取str字符串/json中多级目录下的某个值
2022-02-25 23:07:15
![](https://img.aspxhome.com/file/2023/7/90707_0s.jpg)
Python list与NumPy array 区分详解
2021-08-25 04:12:37
php基于websocket搭建简易聊天室实践
2023-11-17 12:45:42
![](https://img.aspxhome.com/file/2023/1/60391_0s.png)
python os模块简单应用示例
2021-12-20 13:36:48
让复杂导航设计变得简单
2008-01-07 11:50:00
![](https://img.aspxhome.com/file/UploadPic/20081/7/200817122654620s.jpg)
python实现电子词典
2021-12-19 08:29:03
![](https://img.aspxhome.com/file/2023/2/100752_0s.jpg)
go sync Once实现原理示例解析
2023-07-01 12:21:13
PyQt5 QSerialPort子线程操作的实现
2023-08-21 13:07:28
Microsoft SQL Server数据库开发问题详解
2009-10-23 14:16:00
Python实现的扫码工具居然这么好用!
2022-12-13 19:54:03
PHP的mysqli_set_charset()函数讲解
2023-07-11 06:22:17
![](https://img.aspxhome.com/file/2023/7/55457_0s.png)
Dreamweaver MX网页图片热区使用方法
2008-05-20 12:50:00
![](https://img.aspxhome.com/file/UploadPic/20072/200723113613945s.jpg)
详解如何在pyqt中通过OpenCV实现对窗口的透视变换
2021-11-04 07:10:13
![](https://img.aspxhome.com/file/2023/2/82802_0s.gif)