【问题标题】:Getting exceptions recorded in Sentry获取 Sentry 中记录的异常
【发布时间】:2015-04-10 09:05:45
【问题描述】:

我有一个 heroku 后端,所有错误都记录在哨兵中。但是,不会记录任何异常

有没有办法让异常也记录在哨兵中?

这是我的典型哨兵屏幕:http://gyazo.com/3f14899e0a2fb2fb758ba22ae180cf26

我的设置在这里:

# sentry config
# Set your DSN value
RAVEN_CONFIG = {
    'dsn': 'https://ba3cf8050acb4e9b977fde27f30c0bb2:b59c09b7cb0a4b07ae75b08debc3eb24@app.getsentry.com/35850',
}

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'root': {
        'level': 'WARNING',
        'handlers': ['console'],
    },
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'standard': {
            'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s'
        },
    },
    'handlers': {
        'sentry': {
            'level': 'WARNING',
            'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'django.db.backends': {
            'level': 'WARNING',
            'handlers': ['console'],
            'propagate': True,
        },
        'django.request': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': True,
        },
        'raven': {
            'level': 'DEBUG',
            'handlers': ['console'],
            'propagate': False,
        },
        'sentry.errors': {
            'level': 'DEBUG',
            'handlers': ['console', 'sentry'],
            'propagate': False,
        },
        'celery': {
            'level': 'WARNING',
            'handlers': ['sentry', 'console'],
            'propagate': True,
        },
    },
}

# enable 404 logging
MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES + (
  'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
)

【问题讨论】:

    标签: python django exception heroku sentry


    【解决方案1】:

    你有没有added 掠夺到settings.py 文件中的INSTALLED_APPS

    这会导致 Raven 在 Django 中安装一个钩子,该钩子会自动报告未捕获的异常。

    INSTALLED_APPS = (
    # ...
        'raven.contrib.django.raven_compat',
    )
    

    如果您有另一个处理错误和异常的中间件,您必须确保它们仍然通过adding a custom middleware 发送到 Sentry 服务器。

    【讨论】:

    • 是的,我有那段代码和推荐的 404 中间件,还有什么我需要添加的吗?
    猜你喜欢
    • 2020-10-26
    • 2021-09-02
    • 1970-01-01
    • 2020-09-01
    • 1970-01-01
    • 2016-01-06
    • 2021-09-20
    • 2020-10-01
    • 2017-03-23
    相关资源
    最近更新 更多