将Django日志消息存储在数据库中? [英] Store Django Log messages in a database?

查看:287
本文介绍了将Django日志消息存储在数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Django(python网络框架)使用python的日志记录系统来存储日志.

Django (the python web framework) uses python's logging system to store logs.

是否有一种简单的方法将日志消息存储在数据库中,然后允许管理员用户通过Web查看日志消息?我可以自己写这种东西,但是没有必要重新发明轮子.我不想记录异常,但是我已添加到代码中的info/debug/notice类型消息.

Is there an easy way to store log messages in a database, and then allow admin users to look over them via the web? It's the sort of thing I could write myself, but no point re-inventing the wheel. I don't want to log exceptions, but info/debug/notice type messages that I have added to the code.

理想情况下,我希望能够存储有关日志消息的元数据(例如,远程IP地址,用户代理,wsgi进程ID等),然后基于该消息进行过滤/浏览(即显示我在过去24小时内从该IP地址获取的所有日志消息).有人做过吗?

Ideally I'd like to be able to store metadata about the log message as it's done (like the remote IP address, user agent, wsgi process id, etc.), and then filter / browse based on that (i.e. show me all log messages from this IP address in the last 24 hours). Has anyone done this?

推荐答案

只需使用哨兵. Raven ,该功能的Django部分与日志记录框架挂钩,因此除了收集错误外从您的应用中,所有自定义日志消息也应显示.

Just use Sentry. Raven, the Django piece of the functionality hooks into the logging framework, so in addition to collecting errors from your app, any custom log messages should show up as well.

这篇关于将Django日志消息存储在数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆