使用sentry记录错误

使用sentry记录错误

参考https://docs.sentry.io/

记录日志


import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk import capture_exception, capture_message


sentry_logging = LoggingIntegration(
    level=logging.INFO,        # Capture info and above as breadcrumbs
    event_level=logging.ERROR  # Send no events from log messages
)
sentry_sdk.init(
    dsn="https://a777c74e88f1483fb31e5aef953e0d64@sentry.io/179398",
    integrations=[sentry_logging]
)

try:
    1/0
except Exception as e:
    capture_exception(e)


capture_message('Something went wrong')

安装

借鉴 https://app.yinxiang.com/shard/s47/nl/20662749/f1ee3c17-c695-40a0-bbcd-f4258fb4eaa9

  1. git clone https://github.com/getsentry/onpremise.git

  2. docker-compose run –rm web config generate-secret-key 此时会在终端中生成一串秘钥字符串,注意保存它并复制到docker-compose.yml文件中

  3. docker-compose run –rm web upgrade

  4. docker-comose up -d

总结

使用sentry记录日志,可以在线查看

Loading Disqus comments...
Table of Contents