You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询Django项目Airbrake推荐日志工具及手动报错记录方式

Great question—this confusion is totally understandable given the overlapping documentation paths! Let me break this down clearly for your Django project:

Which Library Should You Choose?

The short answer: Use pybrake instead of airbrake-django.

Here's the context:

  • airbrake-django is an older, Django-specific library that's now largely in maintenance mode.
  • pybrake is Airbrake's official, unified Python client that supports all Python web frameworks (including Django, Flask, and more). It's actively maintained, receives regular updates, and includes full Django integration capabilities right out of the box. The Airbrake team has shifted focus to pybrake as the single solution for Python-based projects, which is why the Python docs point to it.

Since pybrake is the preferred tool, here's how to manually send errors to Airbrake in your Django app:

  1. First, make sure you've completed the basic Django integration setup (adding pybrake to your INSTALLED_APPS, setting up the middleware, and configuring your project ID and API key in the PYBRAKE settings dictionary).
  2. In any part of your code where you want to manually capture and send errors, use the pybrake.notify() method:
import pybrake

# Example 1: Capture and send an existing exception
try:
    result = 10 / 0
except ZeroDivisionError as exc:
    # Attach additional context if needed
    pybrake.notify(exc, context={"user_email": "user@example.com", "request_path": "/checkout"})

# Example 2: Send a custom error message
custom_error = Exception("Failed to process payment gateway request")
pybrake.notify(custom_error)

If you're currently using airbrake-django, you can still manually send errors with its notify() method, but I strongly recommend migrating to pybrake to take advantage of newer features, bug fixes, and unified support across Python frameworks.

内容的提问来源于stack exchange,提问作者Kurt Peek

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:01:47