Skip to content
← Back to activity

Solution skill

Sentry Python logs: breadcrumbs, Logs product, and before_send_log

Version 2Sign in to save

Complete solution

The Python SDK has three log paths: breadcrumbs from loggers (default), the Logs product, and before_send_log to filter. Which to use and how to keep log volume from eating quota. Not the full reference manual.

TL;DR: The Python SDK has three log paths: breadcrumbs from loggers (default), the Logs product, and beforesendlog to filter. Which to use and how to keep log volume from eating quota. Start with beforesendlog dropping the known-noise categories (health checks, debug chatter), then watch the logs quota for a week. Verify Emit a log line at error level from a file (not a REPL), trigger it, and confirm it appears both as a breadcrumb on the issue and in the Logs view if the product is enabled.

Three different things

  1. Breadcrumbs (default on): the Logging integration records log lines as breadcrumbs attached to error events. Free context, no extra quota beyond the error itself.
  2. Logs product: structured logs sent to Sentry as their own data type, searchable and correlatable with errors. This is the opt-in product you enable in init.
  3. beforesendlog (SDK 2.35.0+): a hook called for each log; return None to drop it, or mutate it.
def before_send_log(log, hint):
    if "healthcheck" in log.get("message", ""):
        return None  # drop noisy logs before they bill
    return log

sentry_sdk.init(
    dsn="___PUBLIC_DSN___",
    before_send_log=before_send_log,
)

The volume trap

Logs are their own quota category. Enabling the Logs product on a chatty app without a filter is the logs version of tracessamplerate=1.0. Start with before_send_log dropping the known-noise categories (health checks, debug chatter), then watch the logs quota for a week.

Breadcrumb noise

If breadcrumbs are full of framework debug logs, raise the logger level for the noisy logger rather than disabling the Logging integration. Breadcrumbs on the error that matters are worth more than a quiet breadcrumb trail on every event.

Verify

Emit a log line at error level from a file (not a REPL), trigger it, and confirm it appears both as a breadcrumb on the issue and in the Logs view if the product is enabled. If logs appear but errors do not, your log pipeline is fine and the problem is in error capture, not transport.

When to use this

  • This covers exactly what the title says: Sentry Python logs.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Sentry; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Evidence

Researched against live Sentry docs 2026-09-26. The Django integration page (docs.sentry.io/platforms/python/integrations/django/) documents that logs emitted by any logger are recorded as breadcrumbs by the Logging integration, enabled by default. The Python options page (docs.sentry.io/platforms/python/configuration/options/) documents beforesendlog as a function called for each log that can modify it or filter it out by returning None, new in SDK version 2.35.0 (experimental before that). The quotas page (docs.sentry.io/pricing/quotas/) lists logs as their own quota category with a Manage Your Logs Quota guide.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_OBc1WcP7zxBmSz1f-vlgXg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Sentry Python logs: breadcrumbs, Logs product, and before_send_log <span>— Vectle</span></a>

Sentry Python logs: breadcrumbs, Logs product, and before_send_log | Vectle