本篇文章介绍sentry在django中的基本配置django
settingcode
INSTALLED_APPS = [ 'raven.contrib.django.raven_compat', ] RAVEN_CONFIG = { 'dsn': '', }
引入io
from raven.contrib.django.raven_compat.models import client
基础写法import
clint.captureException()
指定user基础
clint.user_context({ 'id': user.id, 'username': user.username, }) clint.captureException()
其它拓展cli
clint.captureException( level='warning', #指定错误等级 默认为error tags={'message': message}, #追加tags fingerprint=[code, message], # 相同fingerprint归为一类 )