Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/platforms/dotnet/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Sets the environment. This string is freeform and set by default. A release can

If you don't set it in code or configuration, the SDK reads the `SENTRY_ENVIRONMENT` environment variable. If that isn't set either:

- ASP.NET Core, Blazor WebAssembly, Google Cloud Functions and .NET Generic Host apps (such as worker services) use the .NET host environment. The SDK lowercases `Production`, `Staging` and `Development` (for consistency with other Sentry SDKs), and keeps other names as they are. Set `AdjustStandardEnvironmentNameCasing` to `false` to keep the original casing.
- ASP.NET Core, Blazor WebAssembly, Google Cloud Functions and [.NET Generic Host](/platforms/dotnet/guides/extensions-hosting/) apps (such as worker services) use the .NET host environment. The SDK lowercases `Production`, `Staging` and `Development` (for consistency with other Sentry SDKs), and keeps other names as they are. Set `AdjustStandardEnvironmentNameCasing` to `false` to keep the original casing.
- Other apps, such as console, MAUI and desktop apps, report `debug` when a debugger is attached, and `production` otherwise. So do ASP.NET Core and Generic Host apps that start Sentry with `SentrySdk.Init` instead of `UseSentry`.

Setting `Scope.Environment` overrides the environment for everything captured with that scope: events, transactions, logs, metrics, sessions, check-ins and trace propagation. Set it to `null` to go back to the default. Sessions and traces use the environment from when they start, so changes to `Scope.Environment` don't affect a session or trace that's already running.
Expand Down
4 changes: 2 additions & 2 deletions docs/platforms/dotnet/guides/azure-functions-worker/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens

**Error Monitoring** starts working as soon as you call `UseSentry` on the host builder. **Logs** sent through `Microsoft.Extensions.Logging` need `EnableLogs = true`, and **Application Metrics** need no extra configuration. You'll learn how to send them in [Send Logs](#send-logs) and [Send Application Metrics](#send-application-metrics-).

`UseSentry` starts Sentry when the host is built and closes it when the host stops. It also adds Sentry's `ILogger` integration, which captures `LogError` and higher as events.
`UseSentry` starts Sentry when the host is built and closes it when the host stops. It also adds Sentry's `ILogger` integration, which captures `LogError` and higher as events. See the [Generic Host](/platforms/dotnet/guides/extensions-hosting/) guide for its configuration options.

This guide also enables **Tracing** through OpenTelemetry. Sentry's OTLP exporter is added to the OpenTelemetry `TracerProviderBuilder`, and `UseOtlp()` tells the Sentry SDK to use OpenTelemetry for tracing.

Expand Down Expand Up @@ -81,7 +81,7 @@ In earlier versions, there was no `Sentry.Extensions.Hosting` package. On those

Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in the options you pass to `UseSentry`.

See [Microsoft.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) for setup details.
See [Generic Host](/platforms/dotnet/guides/extensions-hosting/#send-logs) for setup details.

See <PlatformLink to="/logs/">Set Up Logs</PlatformLink> for all available logging methods and formatting options.

Expand Down
6 changes: 6 additions & 0 deletions docs/product/logs/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ To set up Sentry Logs, use the links below for supported SDKs. After it's been s
url="/platforms/dotnet/guides/maui/logs/"
skill="sentry-dotnet-sdk"
/>
- <LinkWithPlatformIcon
platform="dotnet.extensions-hosting"
label="Generic Host"
url="/platforms/dotnet/guides/extensions-hosting/logs/"
skill="sentry-dotnet-sdk"
/>
- <LinkWithPlatformIcon
platform="dotnet.extensions-logging"
label="Microsoft.Extensions.Logging"
Expand Down
6 changes: 6 additions & 0 deletions docs/product/metrics/getting-started/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ To set up Sentry's Application Metrics, use the links below for supported SDKs.
url="/platforms/dotnet/guides/entityframework/metrics/"
skill="sentry-dotnet-sdk"
/>
- <LinkWithPlatformIcon
platform="dotnet.extensions-hosting"
label="Generic Host"
url="/platforms/dotnet/guides/extensions-hosting/metrics/"
skill="sentry-dotnet-sdk"
/>
- <LinkWithPlatformIcon
platform="dotnet.extensions-logging"
label="Microsoft.Extensions.Logging"
Expand Down
2 changes: 1 addition & 1 deletion includes/dotnet-v7-migration-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The release candidate's `net11.0` builds depend on the .NET 11 versions of `Micr
Version 7 of the Sentry SDK for .NET adds support for .NET 11 and moves SDK initialization out of the logging integrations. The biggest changes are:

- **One place to initialize Sentry.** The Serilog, NLog, log4net and `Microsoft.Extensions.Logging` integrations no longer start the SDK. Call `UseSentry` or `SentrySdk.Init` first, and move the DSN and other SDK settings there.
- **`UseSentry` for generic host apps.** Worker services, Azure Functions isolated worker apps and other apps on the .NET Generic Host can now call `UseSentry` from the new `Sentry.Extensions.Hosting` package.
- **`UseSentry` for generic host apps.** Worker services, Azure Functions isolated worker apps and other apps on the .NET Generic Host can now call `UseSentry` from the new `Sentry.Extensions.Hosting` package. See [Generic Host](/platforms/dotnet/guides/extensions-hosting/).
- **Logs.** Version 7 removes `SentryOptions.EnableLogs`. Structured logs are now enabled automatically if you add the Serilog, NLog or log4net integrations, or call `Logging.AddSentry()` after `SentrySdk.Init`, so check the volume and content of your logs after upgrading if you use any of these integrations.
- **Platforms.** Android, iOS, Mac Catalyst and MAUI apps need .NET 10 or later.
- **Defaults.** The SDK traces fewer incoming requests, and more apps report the host environment instead of `production`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ platformCategory: all
order: 20
---

Worker services, Azure Functions isolated worker apps, Windows services and console apps on `Host.CreateApplicationBuilder` often started Sentry with `Logging.AddSentry`. Install `Sentry.Extensions.Hosting` and call `UseSentry` on the host builder instead.
Worker services, Azure Functions isolated worker apps, Windows services and console apps on `Host.CreateApplicationBuilder` often started Sentry with `Logging.AddSentry`. Install `Sentry.Extensions.Hosting` and call `UseSentry` on the host builder instead. The [Generic Host](/platforms/dotnet/guides/extensions-hosting/) guide shows the full setup.

```shell
dotnet add package Sentry.Extensions.Hosting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Initialize Sentry with the call that matches your app:
| ASP.NET Core | `UseSentry` from `Sentry.AspNetCore` |
| MAUI | `UseSentry` from `Sentry.Maui` |
| Blazor WebAssembly | `UseSentry` from `Sentry.AspNetCore.Blazor.WebAssembly` |
| Worker services, Azure Functions isolated worker apps and other apps on the .NET Generic Host | `UseSentry` from `Sentry.Extensions.Hosting` |
| Worker services, Azure Functions isolated worker apps and other apps on the .NET Generic Host | `UseSentry` from `Sentry.Extensions.Hosting`. See [Generic Host](/platforms/dotnet/guides/extensions-hosting/) |
| Console apps that build their own `ServiceCollection` without a host | `SentrySdk.Init`, then `Logging.AddSentry()`. If the app injects `IHub`, see [IHub Is Registered Only by UseSentry](#ihub-is-registered-only-by-usesentry) |
| Other console apps, ASP.NET on .NET Framework and any other app | `SentrySdk.Init` |

Expand Down
1 change: 1 addition & 0 deletions platform-includes/logs/integrations/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Available integrations:
<ul>
<IntegrationListItem href="/platforms/dotnet/guides/aspnetcore/logs/">ASP.NET Core</IntegrationListItem>
<IntegrationListItem href="/platforms/dotnet/guides/maui/logs/">.NET Multi-platform App UI (.NET MAUI)</IntegrationListItem>
<IntegrationListItem href="/platforms/dotnet/guides/extensions-hosting/logs/">Generic Host</IntegrationListItem>
<IntegrationListItem href="/platforms/dotnet/guides/extensions-logging/logs/">Microsoft.Extensions.Logging</IntegrationListItem>
<IntegrationListItem href="/platforms/dotnet/guides/serilog/logs/">Serilog</IntegrationListItem>
<IntegrationListItem href="/platforms/dotnet/guides/nlog/logs/">NLog</IntegrationListItem>
Expand Down
2 changes: 1 addition & 1 deletion platform-includes/logs/setup/dotnet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SentrySdk.Init(options =>
builder.Logging.AddSentry();
```

Apps on the .NET Generic Host, such as worker services, use `UseSentry` from the `Sentry.Extensions.Hosting` package instead, and set `EnableLogs = true` to send their `ILogger` entries as logs.
Apps on the .NET Generic Host, such as worker services, use `UseSentry` from the `Sentry.Extensions.Hosting` package instead, and set `EnableLogs = true` to send their `ILogger` entries as logs. See [Generic Host](/platforms/dotnet/guides/extensions-hosting/logs/).

<Alert title="Changed in Version 7.0.0">

Expand Down
Loading