Skip to content

docs(dotnet): Show how to turn off logs from Logging.AddSentry() - #20947

Merged
ric-oliv merged 3 commits into
masterfrom
docs/dotnet-logs-off-switch-migration
Nov 24, 2026
Merged

ric-oliv merged 3 commits into
masterfrom
docs/dotnet-logs-off-switch-migration

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

DESCRIBE YOUR PR

Since 7.0.0, apps that call SentrySdk.Init and add Logging.AddSentry() send every ILogger entry to Sentry as a log. The migration guide only shows SetBeforeSendLog(_ => null) to turn that off. That callback still builds each log before it drops it, and it can't be set from configuration. getsentry/sentry-dotnet#5988 asks for a switch that can.

That switch already exists. The logs provider that Logging.AddSentry() adds has the Sentry alias, so setting Logging:Sentry:LogLevel:Default to None turns off its logs and keeps its errors and breadcrumbs. The migration guide now shows it next to SetBeforeSendLog as a second option, in configuration and in code. The same alias is on the logs providers that UseSentry adds in ASP.NET Core and MAUI. The guide also names NLog's minimumLogLevel as that integration's switch, and says that the Serilog sink and the log4net appender have none yet (getsentry/sentry-dotnet#5995, getsentry/sentry-dotnet#5996), so they need the callback. The Logs page already named the alias. It now also says that a LogLevel section under Logging:Sentry applies only to Sentry's logs, and that its keys are categories.

I ran the snippets against Sentry.Extensions.Logging 7.0.0. With None, an info, a warning and an error still produced three breadcrumbs and one event, and no logs. A per-category level under Logging:Sentry changed only which entries became logs and left breadcrumbs unchanged.

Refs getsentry/sentry-dotnet#5988

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace YYYY-MM-DD with the due date. You can update this information later by editing the PR description.

  • Urgent deadline (GA date, etc.): YYYY-MM-DD
  • Other deadline: YYYY-MM-DD
  • No deadline: Not urgent, can wait up to 1 week+

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-docs Ready Ready Preview Nov 24, 2026 9:04am UTC
1 Skipped Deployment
Project Deployment Actions Updated
develop-docs Ignored Ignored Preview Nov 24, 2026 9:04am UTC

Request Review

The v7 migration guide only showed SetBeforeSendLog(_ => null) for
dropping logs. Apps that call SentrySdk.Init and Logging.AddSentry() can
set the Sentry provider's level to None instead, which keeps errors and
breadcrumbs, works from configuration and creates no logs.

Refs getsentry/sentry-dotnet#5988

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Logs page said Sentry's provider has the alias Sentry, but not what
that means for filters, so Logging:Sentry:LogLevel read as if Sentry
were a category. The note now says a LogLevel section under
Logging:Sentry applies only to Sentry's logs and its keys are
categories.

Refs getsentry/sentry-dotnet#5988

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ric-oliv
ric-oliv force-pushed the docs/dotnet-logs-off-switch-migration branch from 989a0a2 to d9c9e51 Compare November 23, 2026 16:37
@ric-oliv
ric-oliv marked this pull request as ready for review November 23, 2026 16:44
@cursor

cursor Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Getting ready to monitor this change · Rollout details

Status Service Environment
⏳ Getting ready to monitor this change

"Set LogLevel to None under Logging:Sentry" reads as
"Sentry": { "LogLevel": "None" }, which Microsoft.Extensions.Logging
ignores. Name the full Logging:Sentry:LogLevel:Default key instead.

The Sentry alias is on every ILogger logs provider, including the ones
UseSentry adds, so drop "works only for Logging.AddSentry()". List
NLog's minimumLogLevel as its switch, and say that the Serilog sink and
the log4net appender have none yet, so they need SetBeforeSendLog.

Link to the filters section on the Extensions.Logging guide, because the
plain .NET Logs page doesn't show it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ric-oliv
ric-oliv merged commit 9bfecaa into master Nov 24, 2026
34 checks passed
@ric-oliv
ric-oliv deleted the docs/dotnet-logs-off-switch-migration branch November 24, 2026 10:22

This branch was successfully deployed

1 active deployment
Preview – sentry-docs — 36464d72 Deployed Nov 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Normal Docs review has no urgent deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants