Skip to main content
 首页 » 编程设计

python之如何正确处理实时 django 站点上的错误

2024年08月28日29JustinYoung

假设我 try catch 并出现异常......在现场生产 (django) 网站上处理这些异常/错误的正确方法是什么?

所以我有

try: 
    create_response = wepay.call('/account/create', 
                                 {'name': name, 'description': desc}) 
    self.wepay_account_id = create_response['account_id'] 
    self.save() 
except WePay.WePayError as e: 
    ..... (what do I put here? 

请您参考如下方法:

您可以通过 Django 设置电子邮件错误报告:https://docs.djangoproject.com/en/dev/howto/error-reporting/

或者您可以使用类似 Rollbar 的服务(有一个免费帐户)来跟踪错误的发生。

或者您可以使用自托管的 Greylog(如评论中建议的那样),这是一个很好的 django 指南:http://www.caktusgroup.com/blog/2013/09/18/central-logging-django-graylog2-and-graypy/