回到顶部

阅读目录

Sentry 错误监控(Django 错误监控)

Sentry 官网

https://sentry.io

邮件提醒

错误列表

Python 安装和使用

Install our Python SDK using pip:

$ pip install --upgrade sentry-sdk==0.9.0

Import and initialize the Sentry SDK early in your application’s setup:

import sentry_sdk
sentry_sdk.init("https://xxxxx@sentry.io/xxxx")

You can cause a Python error by inserting a divide by zero expression into your application:

division_by_zero = 1 / 0

Django 安装和使用

The Django integration adds support for the Django Web Framework from Version 1.6 upwards.

Install sentry-sdk:

$ pip install --upgrade 'sentry-sdk==0.13.2'

To configure the SDK, initialize it with the Django integration in your settings.py file:

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
    dsn="https://xxxxxxxxxxxxxxxx@sentry.io/18xxxx",
    integrations=[DjangoIntegration()]
)

You can easily verify your Sentry installation by creating a route that triggers an error:

from django.urls import path

def trigger_error(request):
    division_by_zero = 1 / 0

urlpatterns = [
    path('sentry-debug/', trigger_error),
    # ...
]

Visiting this route will trigger an error that will be captured by Sentry.

支持的平台或语言

^_^
请喝咖啡 ×

文章部分资料可能来源于网络,如有侵权请告知删除。谢谢!

前一篇: 微信 和 QQ 机器人
下一篇: Python3 + Django + xamdin + DjangoUediter,UEditorField 在 xadmin 下加载不出来的解决办法