diff --git a/docs/platforms/dotnet/guides/aspnet/index.mdx b/docs/platforms/dotnet/guides/aspnet/index.mdx index a49d3a19ad296..ad88f8a70f7f6 100644 --- a/docs/platforms/dotnet/guides/aspnet/index.mdx +++ b/docs/platforms/dotnet/guides/aspnet/index.mdx @@ -33,7 +33,6 @@ You configure the SDK in the `Global.asax.cs`: The snippet also turns on: - Tracing: via `TracesSampleRate` -- Logs from logging integrations: via `EnableLogs` Don't need a feature? Remove its options from the snippet. @@ -58,7 +57,6 @@ public class MvcApplication : HttpApplication options.Debug = true; // Adds request URL and headers, IP and name for users, etc. options.SendDefaultPii = true; - options.EnableLogs = true; // Enables Tracing. // Set to 1.0 to capture 100% of spans for tracing. // We recommend reducing this value in production. @@ -117,9 +115,15 @@ options.AddAspNet(RequestSize.Always); ## Send Logs -Use `SentrySdk.Logger` to send logs at different levels without an additional option. If you also send logs through an integration, set `EnableLogs = true` in the initialization snippet. +Use `SentrySdk.Logger` to send logs at different levels without an additional option. -If you use Serilog, NLog, or log4net, see the documented [Serilog](/platforms/dotnet/guides/serilog/), [NLog](/platforms/dotnet/guides/nlog/), and [log4net](/platforms/dotnet/guides/log4net/) integrations. +If you use Serilog, NLog, or log4net, see the documented [Serilog](/platforms/dotnet/guides/serilog/), [NLog](/platforms/dotnet/guides/nlog/), and [log4net](/platforms/dotnet/guides/log4net/) integrations. They send logs as soon as you add them. To drop logs you don't want, return `null` from `SetBeforeSendLog`. + + + +In earlier versions, the logging integrations only sent logs when `EnableLogs` was set to `true` in `SentrySdk.Init`. + + See Set Up Logs for all available logging methods and formatting options. diff --git a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx index 7fa4beee87e09..68f77532bd81d 100644 --- a/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx +++ b/docs/platforms/dotnet/guides/azure-functions-worker/index.mdx @@ -4,31 +4,33 @@ sdk: sentry.dotnet.azure.functions.worker description: "Learn about Sentry's .NET integration with Azure Functions." --- -Sentry provides an integration with Azure Functions through the [Sentry.Extensions.Logging](https://www.nuget.org/packages/Sentry.Extensions.Logging) and [Sentry.OpenTelemetry.Exporter](https://www.nuget.org/packages/Sentry.OpenTelemetry.Exporter) NuGet packages. +Sentry provides an integration with Azure Functions through the [Sentry.Extensions.Hosting](https://www.nuget.org/packages/Sentry.Extensions.Hosting) and [Sentry.OpenTelemetry.Exporter](https://www.nuget.org/packages/Sentry.OpenTelemetry.Exporter) NuGet packages. ## Install Add the Sentry dependencies to your Azure Functions application: ```shell {tabTitle:.NET Core CLI} -dotnet add package Sentry.Extensions.Logging -v {{@inject packages.version('sentry.dotnet.extensions.logging') }} +dotnet add package Sentry.Extensions.Hosting -v {{@inject packages.version('sentry.dotnet') }} dotnet add package Sentry.OpenTelemetry.Exporter -v {{@inject packages.version('sentry.dotnet') }} dotnet add package OpenTelemetry.Extensions.Hosting dotnet add package OpenTelemetry.Instrumentation.Http ``` ```powershell {tabTitle:Package Manager} -Install-Package Sentry.Extensions.Logging -Version {{@inject packages.version('sentry.dotnet.extensions.logging') }} +Install-Package Sentry.Extensions.Hosting -Version {{@inject packages.version('sentry.dotnet') }} Install-Package Sentry.OpenTelemetry.Exporter -Version {{@inject packages.version('sentry.dotnet') }} Install-Package OpenTelemetry.Extensions.Hosting Install-Package OpenTelemetry.Instrumentation.Http ``` -The [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/) package also provides access to the `ILogger` integration and the other core features available in the [Sentry](/platforms/dotnet/) SDK. +This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extensions-logging/). This means you also get the `ILogger` integration and the other core features available in the [Sentry](/platforms/dotnet/) SDK. ## Configure -**Error Monitoring** starts working as soon as you initialize the SDK by calling `AddSentry` when configuring logging. **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-). +**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. 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. @@ -42,11 +44,17 @@ Don't need a feature? Remove its options from the snippet. ```csharp using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using OpenTelemetry.Trace; var host = new HostBuilder() .ConfigureFunctionsWorkerDefaults() + .UseSentry(options => + { + options.Dsn = "___PUBLIC_DSN___"; + options.EnableLogs = true; + options.UseOtlp(); // <-- Configure Sentry to use OpenTelemetry for tracing + options.Debug = true; + }) .ConfigureServices(services => { services.AddOpenTelemetry().WithTracing(builder => @@ -56,24 +64,22 @@ var host = new HostBuilder() .AddHttpClientInstrumentation(); // From OpenTelemetry.Instrumentation.Http, instruments outgoing HTTP requests }); }) - .ConfigureLogging(logging => - { - logging.AddSentry(options => - { - options.Dsn = "___PUBLIC_DSN___"; - options.EnableLogs = true; - options.UseOtlp(); // <-- Configure Sentry to use OpenTelemetry for tracing - options.Debug = true; - }); - }) .Build(); await host.RunAsync(); ``` +Apps that use the ASP.NET Core integration, with `ConfigureFunctionsWebApplication()` instead of `ConfigureFunctionsWorkerDefaults()`, call the same `UseSentry`, not the one from `Sentry.AspNetCore`. + + + +In earlier versions, there was no `Sentry.Extensions.Hosting` package. On those versions, install `Sentry.Extensions.Logging` and pass the same options to `logging.AddSentry(options => ...)` in `ConfigureLogging`, instead of calling `UseSentry`. + + + ## Send Logs -Use `Microsoft.Extensions.Logging` to send structured logs from your application. Set `EnableLogs = true` in your Sentry initialization. +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. diff --git a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx index bafbb652e24b1..3acc042fcf734 100644 --- a/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx +++ b/docs/platforms/dotnet/guides/blazor-webassembly/index.mdx @@ -25,10 +25,7 @@ This package extends [Sentry.Extensions.Logging](/platforms/dotnet/guides/extens This guide also enables **Tracing**. - -Sentry integration with Blazor WebAssembly is done by calling `.UseSentry()` and specifying the options, for example: - - +Sentry integration with Blazor WebAssembly is done by calling `.UseSentry()` and specifying the options. `UseSentry` also adds Sentry's `ILogger` integration, which captures `LogError` and higher as events. The snippet also turns on: @@ -39,7 +36,6 @@ Don't need a feature? Remove its options from the snippet. ```csharp using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using Microsoft.Extensions.Logging; var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.UseSentry(options => @@ -56,9 +52,6 @@ builder.UseSentry(options => options.TracesSampleRate = 0.1; }); -// Captures logError and higher as events -builder.Logging.AddSentry(o => o.InitializeSdk = false); - await builder.Build().RunAsync(); ``` diff --git a/docs/platforms/dotnet/guides/log4net/index.mdx b/docs/platforms/dotnet/guides/log4net/index.mdx index 99c61499a86b4..c963aa208978d 100644 --- a/docs/platforms/dotnet/guides/log4net/index.mdx +++ b/docs/platforms/dotnet/guides/log4net/index.mdx @@ -7,9 +7,9 @@ og_image: /og-images/platforms-dotnet-guides-log4net.gif Sentry provides an integration with log4net through the [Sentry.Log4Net NuGet package](https://www.nuget.org/packages/Sentry.Log4Net). -Without any code change, this package is able to initialize the Sentry SDK and capture events while including additional properties like `Exception` data and more. +The `SentryAppender` captures log events as Sentry events and breadcrumbs, including additional properties like `Exception` data and more. -Additionally, when enabled, log messages are sent to Sentry as [Structured Logs](logs/). +Log messages are also sent to Sentry as [Structured Logs](logs/). ## Install @@ -27,35 +27,83 @@ This package extends `Sentry` main SDK. That means besides the log4net `Appender ## Configure -Once the log4net integration package is installed in your project, you can modify your configuration file to add the appender. +Initialize Sentry first, with `SentrySdk.Init` or a host integration such as [ASP.NET Core](/platforms/dotnet/guides/aspnetcore/): + +```csharp +SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); +``` + +Then add the appender to your log4net configuration. This can be done, for example, via the `app.config` for console and desktop apps or `web.config` in case of ASP.NET. ```xml {filename:app.config} - ``` - +Other [SDK options](/platforms/dotnet/guides/log4net/configuration/options/) can also be configured when calling `SentrySdk.Init`. -Only a subset of the options are exposed via the log4net appender configuration. If you wish to access an [SDK option](/platforms/dotnet/configuration/options/) which is not listed below, you'll need to initialize the SDK via [SentrySdk.Init](/platforms/dotnet/) instead of doing it via this integration as described below. +The appender drops log events while Sentry isn't initialized. If a DSN can be found anyway, for example in the `SENTRY_DSN` environment variable, the appender also writes a warning to standard error the first time it drops an event. To fix it, initialize Sentry at startup as shown above. - +### Apps That Call UseSentry -### SendIdentity + -In the example above, the `SendIdentity` flag was switched on. The SDK then will take the log4net `Identity` value and report to Sentry as the user's id. +### Capturing Startup Crashes + +`UseSentry` starts Sentry when the host is built or, in ASP.NET Core, when the app starts running. If the app crashes before then, the appender drops the crash. + +To send these crashes, also call `SentrySdk.Init` before you create the builder, and log the crash if startup fails: + +```csharp {filename:Program.cs} +using log4net; -### DSN +using var sentry = SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); -Also in the example above, you can find the DSN being set. That will instruct the `SentryAppender` to initialize the SDK. +var logger = LogManager.GetLogger(typeof(Program)); -This is only one of the ways to initialize the SDK. If you wish to configure the SDK programmatically, you could **leave the DSN out** from the appender configuration section. The SDK needs to be initialized only **once** and since other integrations (like ASP.NET) are also able to initialize the SDK, you only need to pass the DSN to one of these integrations. -One common case to not add the DSN to the XML configuration file (which would initialize it via the log4net integration) is to have full access to the [SDK option](/platforms/dotnet/guides/log4net/configuration/options/). +try +{ + var builder = WebApplication.CreateBuilder(args); + builder.UseSentry(options => + { + options.Dsn = "___PUBLIC_DSN___"; + }); + + var app = builder.Build(); + app.Run(); +} +catch (Exception ex) +{ + logger.Fatal("Application terminated unexpectedly", ex); + throw; +} +finally +{ + LogManager.Shutdown(); +} +``` + +The two initializations don't share anything: + +- `SentrySdk.Init` runs before the app reads `appsettings.json`, so set its DSN in code or with the `SENTRY_DSN` environment variable. +- `UseSentry` doesn't reuse those options. Give it a DSN as well, in its callback or the `Sentry` section. +- Once `UseSentry` starts Sentry, it replaces the first initialization. Crashes before then are sent with the first initialization's options, such as its release and environment. Breadcrumbs logged before then aren't carried over. +- Crashes after then, such as a port that's already in use, are sent by `UseSentry`. `logger.Fatal` doesn't send them a second time. + +### SendIdentity + +In the example above, the `SendIdentity` flag was switched on. The SDK then will take the log4net `Identity` value and report to Sentry as the user's id. ## Verify diff --git a/docs/platforms/dotnet/guides/nlog/configuration/advanced-configuration-example.mdx b/docs/platforms/dotnet/guides/nlog/configuration/advanced-configuration-example.mdx index 4d0fe3d543278..9a701a3340089 100644 --- a/docs/platforms/dotnet/guides/nlog/configuration/advanced-configuration-example.mdx +++ b/docs/platforms/dotnet/guides/nlog/configuration/advanced-configuration-example.mdx @@ -10,7 +10,32 @@ For more information on how to dynamically set event data via `NLog.config`, see -The SDK can be configured via `NLog.config` XML file: +Call `SentrySdk.Init` to initialize the SDK first. SDK options, such as the environment and release, go here: + +```csharp +SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; + options.Environment = "Development"; + options.Release = "my-project-name@2.3.12"; + options.AttachStacktrace = true; + options.SendDefaultPii = true; // Send Personal Identifiable information like the username of the user logged in to the device + options.ShutdownTimeout = TimeSpan.FromSeconds(5); +}); +``` + +```fsharp +SentrySdk.Init(fun options -> + options.Dsn <- "___PUBLIC_DSN___" + options.Environment <- "Development" + options.Release <- "my-project-name@2.3.12" + options.AttachStacktrace <- true + options.SendDefaultPii <- true // Send Personal Identifiable information like the username of the user logged in to the device + options.ShutdownTimeout <- TimeSpan.FromSeconds 5.0) +|> ignore +``` + +Then configure the Sentry target in an `NLog.config` XML file: ```xml {tabTitle:NLog.config} @@ -26,29 +51,15 @@ The SDK can be configured via `NLog.config` XML file: - - - - true - - ``` -Or the SDK can be configured via code: +Or configure the target in code: ```csharp -// Other overloads exist, for example, configure the SDK with only the DSN or no parameters at all. LogManager.Configuration.AddSentry(o => { o.Layout = "${message}"; @@ -89,15 +99,7 @@ LogManager.Configuration.AddSentry(o => o.MinimumBreadcrumbLevel = LogLevel.Debug; // Debug and higher are stored as breadcrumbs (default is Info) o.MinimumEventLevel = LogLevel.Error; // Error and higher is sent as event (default is Error) - // If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If - // nothing is found, SDK is disabled. - o.Dsn = DsnSample; - - o.AttachStacktrace = true; - o.SendDefaultPii = true; // Send Personal Identifiable information like the username of the user logged in to the device - o.IncludeEventDataOnBreadcrumbs = true; // Optionally include event properties with breadcrumbs - o.ShutdownTimeoutSeconds = 5; //Optionally specify user properties via NLog (here using MappedDiagnosticsLogicalContext as an example) o.User = new SentryNLogUser @@ -119,7 +121,6 @@ LogManager.Configuration.AddSentry(o => ``` ```fsharp -// Other overloads exist, for example, configure the SDK with only the DSN or no parameters at all. LogManager.Configuration.AddSentry( fun o -> o.Layout <- "${message}" @@ -128,15 +129,7 @@ LogManager.Configuration.AddSentry( o.MinimumBreadcrumbLevel <- LogLevel.Debug // Debug and higher are stored as breadcrumbs (default is Info) o.MinimumEventLevel <- LogLevel.Error // Error and higher is sent as event (default is Error) - // If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If - // nothing is found, SDK is disabled. - o.Dsn <- DsnSample - - o.AttachStacktrace <- true - o.SendDefaultPii <- true // Send Personal Identifiable information like the username of the user logged in to the device - o.IncludeEventDataOnBreadcrumbs <- true // Optionally include event properties with breadcrumbs - o.ShutdownTimeoutSeconds <- 5 //Optionally specify user properties via NLog (here using MappedDiagnosticsLogicalContext as an example) o.User <- diff --git a/docs/platforms/dotnet/guides/nlog/index.mdx b/docs/platforms/dotnet/guides/nlog/index.mdx index c597b48a3b510..af6576f3d263d 100644 --- a/docs/platforms/dotnet/guides/nlog/index.mdx +++ b/docs/platforms/dotnet/guides/nlog/index.mdx @@ -20,7 +20,7 @@ The default value to report a log entry as an event to Sentry is `Error`. This means that out of the box, any `Error` call will create an `Event` which will include all log messages of level `Info`, `Warn` and also `Error` and `Critical`. -Additionally, when enabled, log messages are sent to Sentry as [Structured Logs](logs/). +Log messages are also sent to Sentry as [Structured Logs](logs/). ## Install @@ -50,55 +50,40 @@ For more information on how to dynamically set event data via `NLog.config`, see -You can configure the Sentry NLog target via code as follows: +Initialize Sentry first, with `SentrySdk.Init` or a host integration such as [ASP.NET Core](/platforms/dotnet/guides/aspnetcore/), then add the target. You can add it in code: ```csharp -LogManager.Configuration = new LoggingConfiguration(); -LogManager.Configuration - .AddSentry(options => - { - // Optionally specify a separate format for message - options.Layout = "${message}"; - // Optionally specify a separate format for breadcrumbs - options.BreadcrumbLayout = "${logger}: ${message}"; - - // Debug and higher are stored as breadcrumbs (default is Info) - options.MinimumBreadcrumbLevel = LogLevel.Debug; - // Error and higher is sent as event (default is Error) - options.MinimumEventLevel = LogLevel.Error; - - // Send the logger name as a tag - options.AddTag("logger", "${logger}"); - - // All Sentry Options are accessible here. - }); +SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); + +var config = new LoggingConfiguration(); +config.AddSentry(options => +{ + // Optionally specify a separate format for message + options.Layout = "${message}"; + // Optionally specify a separate format for breadcrumbs + options.BreadcrumbLayout = "${logger}: ${message}"; + + // Debug and higher are stored as breadcrumbs (default is Info) + options.MinimumBreadcrumbLevel = LogLevel.Debug; + // Error and higher is sent as event (default is Error) + options.MinimumEventLevel = LogLevel.Error; + + // Send the logger name as a tag + options.AddTag("logger", "${logger}"); +}); +LogManager.Configuration = config; ``` -It's also possible to initialize the SDK through the NLog integration (as opposed to using `SentrySdk.Init`). -This is useful when NLog is the only integration being used in your application. To initialize the Sentry SDK through the NLog integration, provide it with the DSN: - - -```csharp -LogManager.Configuration = new LoggingConfiguration(); -LogManager.Configuration - .AddSentry(o => - { - // The NLog integration will initialize the SDK if DSN is set: - o.Dsn = "___PUBLIC_DSN___"; - }); -``` - - - -The SDK needs to be initialized only once. If a `DSN` is made available to this integration, by default it **will** initialize the SDK. If you do not wish to initialize the SDK via this integration, set the `InitializeSdk` flag to **false**. Not providing a DSN or leaving it as `null` instructs the integration not to initialize the SDK and unless another integration initializes it or you call `SentrySdk.Init`, the SDK will stay disabled. - - +The target drops log events while Sentry isn't initialized. If a DSN can be found anyway, for example in the `SENTRY_DSN` environment variable, the target also writes a warning to standard error the first time it drops an event. To fix it, initialize Sentry at startup as shown above. ### Minimum log level Two log levels are used to configure this integration (see options below). One will configure the lowest level required for a log message to become an event (`MinimumEventLevel`) sent to Sentry. The other option (`MinimumBreadcrumbLevel`) configures the lowest level a message has to be to become a breadcrumb. Breadcrumbs are kept in memory (by default the last 100 records) and are sent with events. For example, by default, if you log 100 entries with `logger.Info` or `logger.Warn`, no event is sent to Sentry. If you then log with `logger.Error`, an event is sent to Sentry which includes those 100 `Info` or `Warn` messages. For this to work, `SentryTarget` needs to receive **all** log entries in order to decide what to keep as breadcrumb or sent as event. Make sure to set the `NLog` `LogLevel` configuration to a value lower than what you set for the `MinimumBreadcrumbLevel` and `MinimumEventLevel` to make sure `SentryTarget` receives these log messages. -The SDK can also be configured via `NLog.config` XML file: +The target can also be configured in an `NLog.config` XML file: ```xml {tabTitle:NLog.config} @@ -112,23 +97,11 @@ The SDK can also be configured via `NLog.config` XML file: - - - - - true - + minimumEventLevel="Error" + includeEventDataOnBreadcrumbs="true"> @@ -144,6 +117,61 @@ The SDK can also be configured via `NLog.config` XML file: ``` +### Apps That Call UseSentry + + + +### Capturing Startup Crashes + +`UseSentry` starts Sentry when the host is built or, in ASP.NET Core, when the app starts running. If the app crashes before then, for example while it reads configuration or registers services, the crash isn't sent. + +To send these crashes, also call `SentrySdk.Init` before you create the builder, and log the crash if startup fails: + +```csharp {filename:Program.cs} +using NLog; +using NLog.Config; +using NLog.Extensions.Logging; + +using var sentry = SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); + +var config = new LoggingConfiguration(); +config.AddSentry(); +LogManager.Configuration = config; +var logger = LogManager.GetCurrentClassLogger(); + +try +{ + var builder = WebApplication.CreateBuilder(args); + builder.Logging.AddNLog(new NLogProviderOptions { ReplaceLoggerFactory = true }); + builder.UseSentry(options => + { + options.Dsn = "___PUBLIC_DSN___"; + }); + + var app = builder.Build(); + app.Run(); +} +catch (Exception ex) +{ + logger.Fatal(ex, "Application terminated unexpectedly"); + throw; +} +finally +{ + LogManager.Shutdown(); +} +``` + +The two initializations don't share anything: + +- `SentrySdk.Init` runs before the app reads `appsettings.json`, so set its DSN in code or with the `SENTRY_DSN` environment variable. +- `UseSentry` doesn't reuse those options. Give it a DSN as well, in its callback or the `Sentry` section. +- Once `UseSentry` starts Sentry, it replaces the first initialization. Crashes before then are sent with the first initialization's options, such as its release and environment. Breadcrumbs logged before then aren't carried over. +- Crashes after then, such as a port that's already in use, are sent by `UseSentry`. `logger.Fatal` doesn't send them a second time. + ### Options #### MinimumBreadcrumbLevel @@ -154,10 +182,6 @@ A `LogLevel` that indicates the minimum level a log message needs to be in order A `LogLevel` which indicates the minimum level a log message has to be sent to Sentry as an event. By default this value is `Error`. -#### InitializeSdk - -Whether or not this integration should initialize the SDK. If you intend to call `SentrySdk.Init` yourself you should set this flag to `false`. - #### IgnoreEventsWithNoException To ignore log messages that don't contain an exception. @@ -209,6 +233,7 @@ This snippet includes an intentional error, so you can test that everything is w ## Samples - A [simple example](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.NLog). +- An [example with ASP.NET Core](https://github.com/getsentry/sentry-dotnet/tree/main/samples/Sentry.Samples.AspNetCore.NLog). - Example of [advanced configuration](configuration/advanced-configuration-example/) ## Next Steps diff --git a/docs/platforms/dotnet/guides/serilog/index.mdx b/docs/platforms/dotnet/guides/serilog/index.mdx index be1d4e29a9ed2..2656ff3fd9858 100644 --- a/docs/platforms/dotnet/guides/serilog/index.mdx +++ b/docs/platforms/dotnet/guides/serilog/index.mdx @@ -20,7 +20,7 @@ The default value to report a log entry as an event to Sentry is `Error`. This means that out of the box, any `LogError` call will create an `Event` which will include breadcrumbs for all prior log messages of level `Information`, `Warning`, `Error` and `Critical`. -Additionally, when enabled, log messages are sent to Sentry as [Structured Logs](logs/). You can control which logs are captured using the [Serilog MinimumLogLevel](https://github.com/serilog/serilog/wiki/Configuration-Basics#minimum-level). +Log messages are also sent to Sentry as [Structured Logs](logs/). You can control which logs are captured using the [Serilog MinimumLogLevel](https://github.com/serilog/serilog/wiki/Configuration-Basics#minimum-level). ## Install @@ -44,9 +44,20 @@ Messages logged from assemblies with the name starting with `Sentry` will not ge ## Configure -You can configure the Sentry Serilog sink as follows: +Initialize Sentry first, with `SentrySdk.Init` or a host integration such as [ASP.NET Core](/platforms/dotnet/guides/aspnetcore/), then add the sink: ```csharp +using Sentry.Serilog; +using Serilog; +using Serilog.Events; + +SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; + // Adds properties from the Serilog LogContext to Sentry events + options.UseSerilog(); +}); + Log.Logger = new LoggerConfiguration() .WriteTo.Sentry(o => { @@ -58,6 +69,8 @@ Log.Logger = new LoggerConfiguration() .CreateLogger(); ``` +You can also configure the sink in `appsettings.json`: + ```json {filename:appsettings.json} { "Serilog": { @@ -78,36 +91,67 @@ Log.Logger = new LoggerConfiguration() } ``` -It's also possible to initialize the SDK through the Serilog integration. This is useful when the Serilog is the only integration being used in your application. To initialize the Sentry SDK through the Serilog integration, provide it with the DSN: +The sink drops log events while Sentry isn't initialized. If a DSN can be found anyway, for example in the `SENTRY_DSN` environment variable, the sink also writes a warning to standard error the first time it drops an event. To fix it, initialize Sentry at startup as shown above. +### Apps That Call UseSentry + + + +### Serilog Properties on Events + +`UseSerilog()` copies the properties in Serilog's `LogContext` onto Sentry events as tags. If you initialize Sentry through a host integration, call it on that integration's options, for example in `UseSentry(options => options.UseSerilog())`. + +If you don't call it, the sink does this for you once it's running, so only events captured before then miss the properties. + +### Capturing Startup Crashes + +`UseSentry` starts Sentry when the host is built or, in ASP.NET Core, when the app starts running. If the app crashes before then, for example while it reads configuration or registers services, the crash isn't sent. + +Apps that use Serilog's [two-stage initialization](https://github.com/serilog/serilog-aspnetcore#two-stage-initialization) log these crashes with a bootstrap logger. To send them to Sentry too, also call `SentrySdk.Init` before you create the builder: + +```csharp {filename:Program.cs} +using Sentry.Serilog; +using Serilog; + +using var sentry = SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; + options.UseSerilog(); +}); -```csharp Log.Logger = new LoggerConfiguration() - .WriteTo.Sentry(o => o.Dsn = "___PUBLIC_DSN___") - .CreateLogger(); -``` + .WriteTo.Sentry() + .CreateBootstrapLogger(); -```json {filename:appsettings.json} +try { - "Serilog": { - "Using": [ "Sentry.Serilog" ], - "WriteTo": [ - { - "Name": "Sentry", - "Args": { - "dsn": "___PUBLIC_DSN___" - } - } - ] - } + var builder = WebApplication.CreateBuilder(args); + builder.Services.AddSerilog(config => config.WriteTo.Sentry()); + builder.UseSentry(options => + { + options.Dsn = "___PUBLIC_DSN___"; + options.UseSerilog(); + }); + + var app = builder.Build(); + app.Run(); +} +catch (Exception ex) +{ + Log.Fatal(ex, "Application terminated unexpectedly"); +} +finally +{ + Log.CloseAndFlush(); } ``` - +The two initializations don't share anything: -The SDK only needs to be initialized once. If a `DSN` is made available to this integration, by default it **will** initialize the SDK. If you do not wish to initialize the SDK via this integration, set the `InitializeSdk` flag to **false**. Not providing a DSN or leaving it as `null` instructs the integration not to initialize the SDK and unless another integration initializes it or you call `SentrySdk.Init`, the SDK will stay disabled. - - +- `SentrySdk.Init` runs before the app reads `appsettings.json`, so set its DSN in code or with the `SENTRY_DSN` environment variable. +- `UseSentry` doesn't reuse those options. Give it a DSN as well, in its callback or the `Sentry` section, and call `UseSerilog()` again. +- Once `UseSentry` starts Sentry, it replaces the first initialization. Crashes before then are sent with the first initialization's options, such as its release and environment. Breadcrumbs logged before then aren't carried over. +- Crashes after then, such as a port that's already in use, are sent by `UseSentry`. `Log.Fatal` doesn't send them a second time. ### Options @@ -119,10 +163,6 @@ A `LogLevel` which indicates the minimum level a log message has to be included A `LogLevel` which indicates the minimum level a log message has to be sent to Sentry as an event. By default this value is `Error`. -#### InitializeSdk - -Whether or not this integration should initialize the SDK. If you intend to call `SentrySdk.Init` yourself you should set this flag to `false`. - #### RestrictedToMinimumLevel `MinimumBreadcrumbLevel` and `MinimumEventLevel` determine what the sink does with a log event, but every log event the logger captures still reaches the sink. If your logger's minimum level is verbose — for example, because another sink writes debug logs to a file — you can use Serilog's [per-sink minimum level](https://github.com/serilog/serilog/wiki/Configuration-Basics#overriding-per-sink) to stop lower-level log events from reaching Sentry entirely. diff --git a/includes/dotnet-usesentry-logging/log4net.mdx b/includes/dotnet-usesentry-logging/log4net.mdx new file mode 100644 index 0000000000000..3da0550448848 --- /dev/null +++ b/includes/dotnet-usesentry-logging/log4net.mdx @@ -0,0 +1,10 @@ +If an app that calls `UseSentry` also sends `ILogger` entries to log4net, for example with `AddLog4Net()` from the `Microsoft.Extensions.Logging.Log4Net.AspNetCore` package, both the appender and the `ILogger` integration that `UseSentry` adds capture each entry. Turn off events and breadcrumbs from the `ILogger` integration and leave `EnableLogs` off, so each entry reaches Sentry once, through the appender: + +```csharp {filename:Program.cs} +builder.UseSentry(options => +{ + options.Dsn = "___PUBLIC_DSN___"; + options.MinimumBreadcrumbLevel = LogLevel.None; + options.MinimumEventLevel = LogLevel.None; +}); +``` diff --git a/includes/dotnet-usesentry-logging/nlog.mdx b/includes/dotnet-usesentry-logging/nlog.mdx new file mode 100644 index 0000000000000..6872599cff13e --- /dev/null +++ b/includes/dotnet-usesentry-logging/nlog.mdx @@ -0,0 +1,15 @@ +In an app that calls `UseSentry`, add NLog with `AddNLog` from the `NLog.Extensions.Logging` package, and set `ReplaceLoggerFactory`: + +```csharp {filename:Program.cs} +var config = new LoggingConfiguration(); +config.AddSentry(); +LogManager.Configuration = config; + +builder.Logging.AddNLog(new NLogProviderOptions { ReplaceLoggerFactory = true }); +builder.UseSentry(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); +``` + +`ReplaceLoggerFactory` replaces the app's `ILogger` factory with NLog's, so each `ILogger` entry reaches Sentry once, through the target. Without it, NLog runs alongside the `ILogger` integration that `UseSentry` adds, and Sentry receives every entry twice. NLog's rules then decide which entries are logged, instead of the `Logging` section of your configuration. In ASP.NET Core, `UseNLog` from the `NLog.Web.AspNetCore` package takes the same option. diff --git a/includes/dotnet-usesentry-logging/serilog.mdx b/includes/dotnet-usesentry-logging/serilog.mdx new file mode 100644 index 0000000000000..b3217b95ba4b5 --- /dev/null +++ b/includes/dotnet-usesentry-logging/serilog.mdx @@ -0,0 +1,12 @@ +In an app that calls `UseSentry`, add Serilog to the builder's services with `AddSerilog` from the `Serilog.Extensions.Hosting` package, and add the sink there: + +```csharp {filename:Program.cs} +builder.Services.AddSerilog(config => config.WriteTo.Sentry()); +builder.UseSentry(options => +{ + options.Dsn = "___PUBLIC_DSN___"; + options.UseSerilog(); +}); +``` + +`AddSerilog` replaces the app's `ILogger` factory with Serilog's, so each `ILogger` entry reaches Sentry once, through the sink. Don't use `builder.Logging.AddSerilog()` or `writeToProviders: true` instead. Both also send each entry through the `ILogger` integration that `UseSentry` adds, so Sentry receives it twice. diff --git a/platform-includes/configuration/config-intro/dotnet.nlog.mdx b/platform-includes/configuration/config-intro/dotnet.nlog.mdx deleted file mode 100644 index fcde9145aad18..0000000000000 --- a/platform-includes/configuration/config-intro/dotnet.nlog.mdx +++ /dev/null @@ -1,87 +0,0 @@ - - -For more information on how to dynamically set event data via `NLog.config`, see NLog's [layout renderer documentation](https://nlog-project.org/config/?tab=layout-renderers). - - - -You can configure the Sentry NLog target via `NLog.config` or by code as follows: - - -```xml {tabTitle:NLog.config} - - - - - - - - - - - - - - - - - - - -``` - -```csharp -using NLog; -using Sentry.NLog; - -LogManager.Configuration.AddSentry(o => -{ - // Optionally specify a separate format for message - o.Layout = "${message}"; - // Optionally specify a separate format for breadcrumbs - o.BreadcrumbLayout = "${logger}: ${message}"; - - // Debug and higher are stored as breadcrumbs (default is Info) - o.MinimumBreadcrumbLevel = LogLevel.Debug; - - // Error and higher is sent as event (default is Error) - o.MinimumEventLevel = LogLevel.Error; - - // Send the logger name as a tag - o.AddTag("logger", "${logger}"); - - // All Sentry Options are accessible here. -}); -``` - -```fsharp -open NLog -open Sentry.NLog - -LogManager.Configuration.AddSentry( - fun o -> - // Optionally specify a separate format for message - o.Layout <- "${message}" - // Optionally specify a separate format for breadcrumbs - o.BreadcrumbLayout <- "${logger}: ${message}" - - // Debug and higher are stored as breadcrumbs (default is Info) - o.MinimumBreadcrumbLevel <- LogLevel.Debug - - // Error and higher is sent as event (default is Error) - o.MinimumEventLevel <- LogLevel.Error - - // Send the logger name as a tag - o.AddTag("logger", "${logger}") - - // All Sentry Options are accessible here. -) -``` diff --git a/platform-includes/enriching-events/set-tag/dotnet.nlog.mdx b/platform-includes/enriching-events/set-tag/dotnet.nlog.mdx index 346787f21dac8..205b0cf88aa54 100644 --- a/platform-includes/enriching-events/set-tag/dotnet.nlog.mdx +++ b/platform-includes/enriching-events/set-tag/dotnet.nlog.mdx @@ -15,7 +15,7 @@ For more information on how to dynamically set event tags via `NLog.config`, see - + @@ -29,7 +29,6 @@ For more information on how to dynamically set event tags via `NLog.config`, see ```csharp LogManager.Configuration.AddSentry(options => { - options.Dsn = "___PUBLIC_DSN___"; // Tags configured on the target can use NLog layouts options.AddTag("logger", "${logger}"); }); @@ -38,7 +37,6 @@ LogManager.Configuration.AddSentry(options => ```fsharp LogManager.Configuration.AddSentry( fun options -> - options.Dsn <- "___PUBLIC_DSN___" // Tags configured on the target can use NLog layouts options.AddTag("logger", "${logger}") ) |> ignore diff --git a/platform-includes/enriching-events/set-user/dotnet.nlog.mdx b/platform-includes/enriching-events/set-user/dotnet.nlog.mdx index 28ec6343db210..5a0a64254a568 100644 --- a/platform-includes/enriching-events/set-user/dotnet.nlog.mdx +++ b/platform-includes/enriching-events/set-user/dotnet.nlog.mdx @@ -15,7 +15,7 @@ - + @@ -29,7 +29,7 @@ ```csharp SentrySdk.ConfigureScope(scope => { - scope.User = new User + scope.User = new SentryUser { Email = "john.doe@example.com" }; @@ -39,7 +39,7 @@ SentrySdk.ConfigureScope(scope => ```fsharp SentrySdk.ConfigureScope( fun scope -> - scope.User <- User(Email = "john.doe@example.com") + scope.User <- SentryUser(Email = "john.doe@example.com") () ) ``` diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index ed7e850819e0d..f62c4077bbdd8 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -1,33 +1,24 @@ + + #### EnableLogs - -Set to `true` to send logs captured by logging integrations, such as `Microsoft.Extensions.Logging`, Serilog, NLog, and log4net. Defaults to `false`. +Set to `true` to send the entries your app writes through the `ILogger` API to Sentry as logs. Defaults to `false`. -Since version 6.10.0, this option doesn't apply to logs sent through the `SentrySdk.Logger` APIs. Those logs are always sent. - +This option doesn't apply to logs sent through the `SentrySdk.Logger` APIs or through the Serilog, NLog, and log4net integrations. Those logs are always sent. - -Set to `true` in order to enable the logging integration via the `ILogger` API. - + - -Set to `true` in order to enable the logging integration via the `Log`/`Logger` APIs. - +In earlier versions, `EnableLogs` was an option on `SentryOptions`, and the Serilog, NLog, and log4net integrations only sent logs when it was `true`. - -Set to `true` in order to enable the logging integration via the NLog `Logger` APIs. - + - -Set to `true` in order to enable the logging integration via the log4net `ILog` APIs. - + #### Configure Microsoft.Extensions.Logging Filters -In apps that use `Microsoft.Extensions.Logging`, setting `EnableLogs = true` enables Sentry's `Microsoft.Extensions.Logging` integration. -Sentry's provider defines the alias `Sentry`. +Sentry's `Microsoft.Extensions.Logging` provider defines the alias `Sentry`. Logs emitted through `ILogger` are sent to Sentry according to your configured provider/category filters and log levels. @@ -51,7 +42,7 @@ Use standard `Microsoft.Extensions.Logging` filtering to reduce noisy categories Setting `Logging:Sentry:LogLevel:Default` to `None` disables logs sent through the `Microsoft.Extensions.Logging` provider for all categories. Logs sent through the `SentrySdk.Logger` APIs aren't affected by these filters and are still sent. -Example with `EnableLogs = true` and `Logging:Sentry:LogLevel:Default = None`: +Example with `Logging:Sentry:LogLevel:Default = None`: ```csharp logger.LogInformation("Will not be sent to Sentry through Microsoft.Extensions.Logging"); @@ -80,7 +71,6 @@ To filter logs or update them before they are sent to Sentry, you can use the `S options => { options.Dsn = "___PUBLIC_DSN___"; - options.EnableLogs = true; // a callback that is invoked before sending a log to Sentry options.SetBeforeSendLog(static log => { diff --git a/platform-includes/logs/requirements/dotnet.mdx b/platform-includes/logs/requirements/dotnet.mdx index 33859401902c3..082e175707d43 100644 --- a/platform-includes/logs/requirements/dotnet.mdx +++ b/platform-includes/logs/requirements/dotnet.mdx @@ -1,7 +1,11 @@ - + Logs for are supported in Sentry SDK version `5.14.0` and above. + +Logs for are supported in Sentry SDK version `7.0.0` and above. + + Logs for are supported in Sentry SDK version `5.16.0` and above. diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index 8cbc3217063c1..8327cd3f626ff 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -1,6 +1,6 @@ -Logs sent through the `SentrySdk.Logger` APIs are always sent, so they don't need any extra configuration. To send logs captured by logging integrations, initialize the SDK with the `EnableLogs` option set to `true`. +Logs sent through the `SentrySdk.Logger` APIs are always sent, so they don't need any extra configuration. - + ```csharp SentrySdk.Init(options => @@ -9,99 +9,166 @@ SentrySdk.Init(options => }); ``` -You don't need a logs-specific option to use the `SentrySdk.Logger` APIs. Set `EnableLogs = true` only if you also send logs through a logging integration. +The Serilog, NLog, log4net, and `Microsoft.Extensions.Logging` integrations also send logs without a logs-specific option. + + + +In earlier versions, these integrations only sent logs when `EnableLogs` was `true`. + + - + + +To also send the entries your app writes through `ILogger`, set `EnableLogs` to `true`: ```csharp {tabTitle:Builder} .UseSentry(options => { options.Dsn = "___PUBLIC_DSN___"; - // Enable logs to be sent to Sentry + // Send ILogger entries to Sentry as logs options.EnableLogs = true; }); ``` + + + -This enables the `Microsoft.Extensions.Logging` integration. The `SentrySdk.Logger` APIs don't depend on `EnableLogs`. +```json {tabTitle:Configuration} {filename:appsettings.json} +{ + "Sentry": { + "Dsn": "___PUBLIC_DSN___", + "EnableLogs": true + } +} +``` + + + + + +If your app also sends `ILogger` entries through Serilog, NLog, or log4net, leave `EnableLogs` off and set up the framework as shown below, so each entry reaches Sentry once. + + + + + + + + + + + + + + + + + + -```csharp {tabTitle:Factory} -.AddSentry(options => +Initialize the SDK with `SentrySdk.Init`, then add Sentry to your logging builder. Entries your app writes through `ILogger` are then sent as logs, without a logs-specific option. + +```csharp +SentrySdk.Init(options => { options.Dsn = "___PUBLIC_DSN___"; - // Enable logs to be sent to Sentry - options.EnableLogs = true; }); + +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. - + -```json {tabTitle:Configuration} {filename:appsettings.json} -{ - "Sentry": { - "Dsn": "___PUBLIC_DSN___", - "EnableLogs": true - } -} -``` +In earlier versions, `AddSentry` initialized the SDK itself and only sent logs when `EnableLogs` was `true`. On those versions, set the DSN and `EnableLogs` in `AddSentry(options => ...)` instead of calling `SentrySdk.Init`. + + +Initialize the SDK, then add the Sentry sink. The sink sends logs as soon as you add it. + ```csharp -.WriteTo.Sentry(options => +SentrySdk.Init(options => { options.Dsn = "___PUBLIC_DSN___"; - // Enable logs to be sent to Sentry - options.EnableLogs = true; }); -``` +Log.Logger = new LoggerConfiguration() + .WriteTo.Sentry() + .CreateLogger(); +``` +Initialize the SDK, then add the Sentry target, in code or in your `NLog.config`. The target sends logs as soon as you add it. + ```csharp -LogManager.Configuration = new LoggingConfiguration(); -LogManager.Configuration - .AddSentry(options => - { - options.Dsn = "___PUBLIC_DSN___"; - // Enable logs to be sent to Sentry - options.EnableLogs = true; - }); -``` +SentrySdk.Init(options => +{ + options.Dsn = "___PUBLIC_DSN___"; +}); -If the SDK is initialized elsewhere (for example, through ASP.NET Core), enable `EnableLogs` on those options instead. The NLog target then captures logs without initializing the SDK itself. +var config = new LoggingConfiguration(); +config.AddSentry(); +LogManager.Configuration = config; +``` -`EnableLogs` isn't exposed as a log4net appender setting, so initialize the SDK with `SentrySdk.Init` and leave the DSN out of your log4net appender configuration. +Initialize the SDK. The `SentryAppender` in your log4net configuration then sends logs. ```csharp SentrySdk.Init(options => { options.Dsn = "___PUBLIC_DSN___"; - // Enable logs to be sent to Sentry - options.EnableLogs = true; }); ``` -The `SentryAppender` configured in your log4net configuration then captures logs without initializing the SDK itself. If the SDK is initialized elsewhere (for example, through ASP.NET Core), enable `EnableLogs` on those options instead. + + + + +If the SDK is initialized elsewhere, for example by `UseSentry`, skip `SentrySdk.Init`. + + + +In earlier versions, this integration only sent logs when `EnableLogs` was set to `true` on the options used to initialize the SDK. + + -It does _not_ capture the `Console.WriteLine()` standard output stream. + + + + + + + + + + + + + + + + + +It does _not_ capture the `Console.WriteLine()` standard output stream. diff --git a/platform-includes/logs/usage/dotnet.mdx b/platform-includes/logs/usage/dotnet.mdx index 794c46b4a8ee3..84f61fedc237c 100644 --- a/platform-includes/logs/usage/dotnet.mdx +++ b/platform-includes/logs/usage/dotnet.mdx @@ -1,4 +1,4 @@ - + Once the SDK is initialized, you can send logs using the `SentrySdk.Logger` APIs. @@ -13,7 +13,7 @@ SentrySdk.Logger.LogError("A {0} log message", "formatted"); - + Once the feature is enabled and the SDK is initialized, you can send logs using instances of the [ILogger](https://learn.microsoft.com/dotnet/api/microsoft.extensions.logging.ilogger-1) interface, resolved through [.NET dependency injection](https://learn.microsoft.com/dotnet/core/extensions/dependency-injection/overview). @@ -53,7 +53,7 @@ Sentry Structured Logs also work with [High-performance logging in .NET](https:/ -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the _Serilog_ APIs. +Once the SDK is initialized and the Sentry sink is added, you can send logs using the _Serilog_ APIs. The static `Log` and instance `Logger` types expose various methods that you can use to log messages at six different log levels automatically mapped to Sentry's severity: @@ -83,7 +83,7 @@ The _Enrichments_ of _log events_ are attached as attributes to the logs, alongs -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the _NLog_ APIs. +Once the SDK is initialized and the Sentry target is added, you can send logs using the _NLog_ APIs. The `Logger` type exposes various methods that you can use to log messages at six different log levels automatically mapped to Sentry's severity: @@ -112,7 +112,7 @@ The _properties_ of _log events_ are attached as attributes to the logs, alongsi -Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the _log4net_ APIs, for example through the `ILog` methods (`Debug`, `Info`, `Warn`, `Error`, and `Fatal`). +Once the SDK is initialized and the `SentryAppender` is configured, you can send logs using the _log4net_ APIs, for example through the `ILog` methods (`Debug`, `Info`, `Warn`, `Error`, and `Fatal`). log4net levels are automatically mapped to Sentry's severity: @@ -139,13 +139,13 @@ Log.Warn("Message with a custom property"); The log4net _properties_ (from the log event, `ThreadContext`, and `GlobalContext`) are attached as `property.` attributes to the logs, alongside a set of default attributes automatically provided by the SDK. The logger name is attached as the `category.name` attribute. -The `SentryAppender`'s `Environment` and `SendIdentity` settings also apply to structured logs: when configured, `Environment` sets the log's environment and `SendIdentity` attaches the log4net identity as the user. +The `SentryAppender`'s `SendIdentity` setting also applies to structured logs: when configured, it attaches the log4net identity as the user. Because log4net renders each message before it reaches the appender, structured logs from log4net carry the fully-formatted message but no message template or parameters. - + The SDK automatically provides a set of default attributes attached to your logs. Additionally, you can attach custom attributes via a delegate. diff --git a/platform-includes/metrics/options/dotnet.mdx b/platform-includes/metrics/options/dotnet.mdx index 66cf538065ca1..b895616385f38 100644 --- a/platform-includes/metrics/options/dotnet.mdx +++ b/platform-includes/metrics/options/dotnet.mdx @@ -1,6 +1,6 @@ #### EnableMetrics -This option is obsolete and ignored since version 6.10.0, and will be removed in version 7.0.0. Metrics sent through the `SentrySdk.Metrics` APIs are always sent, even if you set `EnableMetrics` to `false`. To drop metrics, use `SetBeforeSendMetric` and return `null`. +This option was removed in version 7.0.0, and has been ignored since version 6.10.0. Metrics sent through the `SentrySdk.Metrics` APIs are now always sent. To drop metrics, use `SetBeforeSendMetric` and return `null`. #### SetBeforeSendMetric diff --git a/platform-includes/set-environment/dotnet.nlog.mdx b/platform-includes/set-environment/dotnet.nlog.mdx deleted file mode 100644 index 9b31a70582387..0000000000000 --- a/platform-includes/set-environment/dotnet.nlog.mdx +++ /dev/null @@ -1,40 +0,0 @@ - - -For more information on how to dynamically set event data via `NLog.config`, see NLog's [layout renderer documentation](https://nlog-project.org/config/?tab=layout-renderers). - - - - -```xml {tabTitle:NLog.config} - - - - - - - - - - - - - - - -``` - -```csharp -// Add this to the SDK initialization callback -options.Environment = "production"; -``` - -```fsharp -// Add this to the SDK initialization callback -options.Environment <- "production" -``` diff --git a/platform-includes/set-release/dotnet.nlog.mdx b/platform-includes/set-release/dotnet.nlog.mdx deleted file mode 100644 index 7972d4f355bd3..0000000000000 --- a/platform-includes/set-release/dotnet.nlog.mdx +++ /dev/null @@ -1,46 +0,0 @@ - - -For more information on how to dynamically set event data via `NLog.config`, see NLog's [layout renderer documentation](https://nlog-project.org/config/?tab=layout-renderers). - - - - -```xml {tabTitle:NLog.config} - - - - - - - - - - - - - - -``` - -```csharp -// Add this to the SDK initialization callback -options.Release = "my-project-name@2.3.12"; -``` - -```fsharp -// Add this to the SDK initialization callback -options.Release <- "my-project-name@2.3.12" -``` - -The SDK attempts to locate the release to add to events sent to Sentry. - -The SDK will first look at the [entry assembly's]() `AssemblyInformationalVersionAttribute`, which accepts a string as -value and is often used to set a GIT commit hash. - -If that returns null, it'll look at the default `AssemblyVersionAttribute` which accepts the numeric version number.