当 Debug = True 时 Django 错误报告电子邮件
有没有办法让 Django 通过电子邮件向我发送错误报告,即使我将调试设置为 True?
我在文档中没有看到任何内容。
编辑:
如果重要的话,我正在使用 Django 1.2。 不,这不是生产系统。
Is there a way to get Django to email me error reports even though I have debug set to True?
I didn't see anything in the docs.
Edit:
I'm on Django 1.2 if it matters.
No, this isn't a production system.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您只有一封电子邮件,请确保列表中有逗号:
我尝试了这些并且似乎有效:
If you only have one email, make sure you have a comma in the list:
I tried these and seems work:
您可能想查看 django-sentry。它确实是为在生产中使用而设计的,但它具有
TESTING
设置,使其在DEBUG=True
时也能工作。它实际上也可能在那时发送电子邮件——我自己还没有测试过,但它至少会保留错误日志,您可以随时从任何支持网络的设备查看。此外,当您最终投入生产时,它将成为您的救星。
You might want to look at django-sentry. It's really designed for use in production, but it has
TESTING
setting to make it work whenDEBUG=True
as well. It might actually send out emails at that point, too -- haven't tested that myself, but it'll at least keep a log of errors that you can view at any time from any web-enabled device.Besides, when you do eventually go to production, it'll be a life-saver.
只是为了稍微扩展一下 Bob Roberts 的答案,我在 django.utils.log 中找到了默认的日志配置。您只需将其复制并粘贴到您的设置中,将其命名为
LOGGING
,然后更改行:Just to expand on Bob Roberts answer a bit, I found the default logging configuration in
django.utils.log
. You can just copy and paste it to your settings, name itLOGGING
, and change the line:我相信您可以通过为与 settings.py 中定义的 AdminEmailHandler 关联的过滤器指定一个空列表来实现这一点。
例如:
默认情况下,此类的过滤器是 django.utils.log.RequireDebugFalse。
I believe you can achieve that by specifying an empty list to the filters associated with your AdminEmailHandler defined in your settings.py.
For instance:
By default the filters for this class would be a django.utils.log.RequireDebugFalse.
将以下行添加到您的 settings.py 文件中应该可以解决问题。
Adding the following line to your settings.py file should do the trick.