python - nginx gunicorn 记录请求和响应内容
PHP中文网
PHP中文网 2017-04-17 17:56:34
0
1
353

服务器用nginx和gunicorn部署的,上面跑了很多Django的网站。现在想对响应状态码是50x的请求和想要都做一个记录,便于及时发现和解决问题。
因为对Python的使用比较顺手,所以倾向于在gunicorn的Python配置文件中做记录,研究了一下post_request钩子,但是这里面的request和response都只能拿到简单的信息,正文内容好像没法直接获取。
去配置nginx的话,感觉会不会又变复杂了。
有做过类似事情的朋友吗,支支招,谢谢~

补充:
request的body已经通过req.body.read()获取到了,response现在还没有办法。

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
左手右手慢动作

This should be done in Nginx, maybe you will throw an exception in post_request

You can use the popular openresty

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!