Repository navigation
Commit 9bfecaa
docs(dotnet): Show how to turn off logs from Logging.AddSentry() (#20947)
## 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
- [x] No deadline: Not urgent, can wait up to 1 week+
## PRE-MERGE CHECKLIST
_Make sure you've checked the following before merging your changes:_
- [x] Checked Vercel preview for correctness, including links
- [x] 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](https://github.com/orgs/getsentry/teams/docs)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 0bcc054 commit 9bfecaa
3 files changed
Lines changed: 37 additions & 5 deletions
File tree
- includes/migration/dotnet-v7
- platform-includes/logs/options
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
| |||
42 | 49 | | |
43 | 50 | | |
44 | 51 | | |
45 | | - | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
0 commit comments