From 320a63d07b9d6f12b6994354fe33bcb6d7ea39c2 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 16 Jul 2026 11:57:44 +1200 Subject: [PATCH 1/2] docs(dotnet/logs): add NLog structured logs integration Document the NLog structured-logs integration added in getsentry/sentry-dotnet#5176, mirroring the existing Serilog logs docs: - Enable the Logs page for the NLog guide (remove from notSupported) - Add NLog setup, usage, options, requirements and integration-list entries - List NLog on the product Logs getting-started page Co-Authored-By: Claude Opus 4.8 Signed-off-by: James Crosswell --- docs/platforms/dotnet/common/logs/index.mdx | 1 - docs/platforms/dotnet/guides/nlog/index.mdx | 5 ++- docs/product/logs/getting-started/index.mdx | 6 ++++ .../logs/integrations/dotnet.mdx | 1 + platform-includes/logs/options/dotnet.mdx | 6 +++- .../logs/requirements/dotnet.mdx | 6 +++- platform-includes/logs/setup/dotnet.mdx | 19 ++++++++++- platform-includes/logs/usage/dotnet.mdx | 33 +++++++++++++++++-- 8 files changed, 70 insertions(+), 7 deletions(-) diff --git a/docs/platforms/dotnet/common/logs/index.mdx b/docs/platforms/dotnet/common/logs/index.mdx index 6482e81370dc9d..1045c631515a80 100644 --- a/docs/platforms/dotnet/common/logs/index.mdx +++ b/docs/platforms/dotnet/common/logs/index.mdx @@ -7,7 +7,6 @@ sidebar_section: features notSupported: - dotnet.google-cloud-functions - dotnet.log4net - - dotnet.nlog - dotnet.xamarin --- diff --git a/docs/platforms/dotnet/guides/nlog/index.mdx b/docs/platforms/dotnet/guides/nlog/index.mdx index 1e4fae1abe5a7a..0a840be059cde5 100644 --- a/docs/platforms/dotnet/guides/nlog/index.mdx +++ b/docs/platforms/dotnet/guides/nlog/index.mdx @@ -9,7 +9,8 @@ Sentry provides an integration with `NLog` through the [Sentry.NLog NuGet packag ## Overview of the features - Store log messages as breadcrumbs -- Send events to sentry +- Send events to Sentry +- Send structured logs to Sentry Two separate settings define the minimum log level to keep the log entry as a `Breadcrumb` and to send an `Event` to Sentry. The events include any stored breadcrumb on that [scope](enriching-events/scopes/). @@ -19,6 +20,8 @@ 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/). + ## Install Add the Sentry dependency: diff --git a/docs/product/logs/getting-started/index.mdx b/docs/product/logs/getting-started/index.mdx index 10d82fbc7a1fd8..c6c6afcb64e01a 100644 --- a/docs/product/logs/getting-started/index.mdx +++ b/docs/product/logs/getting-started/index.mdx @@ -332,6 +332,12 @@ To set up Sentry Logs, use the links below for supported SDKs. After it's been s url="/platforms/dotnet/guides/serilog/logs/" skill="sentry-dotnet-sdk" /> +- ### Native diff --git a/platform-includes/logs/integrations/dotnet.mdx b/platform-includes/logs/integrations/dotnet.mdx index cbc91c391bed56..5ed99c641fe605 100644 --- a/platform-includes/logs/integrations/dotnet.mdx +++ b/platform-includes/logs/integrations/dotnet.mdx @@ -4,6 +4,7 @@ Available integrations: .NET Multi-platform App UI (.NET MAUI) Microsoft.Extensions.Logging Serilog +NLog If there's an integration you would like to see, open a [new issue on GitHub](https://github.com/getsentry/sentry-dotnet/issues/new/choose). diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index 7d20f79800a624..7868266edecf90 100644 --- a/platform-includes/logs/options/dotnet.mdx +++ b/platform-includes/logs/options/dotnet.mdx @@ -1,6 +1,6 @@ #### EnableLogs - + Set to `true` in order to enable the `SentrySdk.Logger` APIs. @@ -12,6 +12,10 @@ Set to `true` in order to enable the logging integration via the `ILogger + +Set to `true` in order to enable the logging integration via the NLog `Logger` APIs. + + #### Configure Microsoft.Extensions.Logging Filters diff --git a/platform-includes/logs/requirements/dotnet.mdx b/platform-includes/logs/requirements/dotnet.mdx index 3f0941afd2f207..19058c96110b08 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 `5.16.0` and above. + + +Logs for are supported in Sentry SDK version `6.7.0` and above. + diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index d1b49377162331..88cdfaa1e8bc6f 100644 --- a/platform-includes/logs/setup/dotnet.mdx +++ b/platform-includes/logs/setup/dotnet.mdx @@ -1,6 +1,6 @@ To enable logging, you need to initialize the SDK with the `EnableLogs` option set to `true`. - + ```csharp SentrySdk.Init(options => @@ -70,6 +70,23 @@ This enables the `SentrySdk.Logger` APIs, as well as the `Microsoft.Extensions.L ``` + + + + +```csharp +LogManager.Configuration = new LoggingConfiguration(); +LogManager.Configuration + .AddSentry(options => + { + options.Dsn = "___PUBLIC_DSN___"; + // Enable logs to be sent to Sentry + options.EnableLogs = true; + }); +``` + +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. + 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 19ae34be91bcca..f1b977c4fb868f 100644 --- a/platform-includes/logs/usage/dotnet.mdx +++ b/platform-includes/logs/usage/dotnet.mdx @@ -1,4 +1,4 @@ - + Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `SentrySdk.Logger` APIs. @@ -81,7 +81,36 @@ 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. + +The `Logger` type exposes various methods that you can use to log messages at six different log levels automatically mapped to Sentry's severity: + +| NLog.LogLevel | Sentry.SentryLogLevel | Sentry Logs UI Severity | +| --- | --- | --- | +| Trace | Trace | trace | +| Debug | Debug | debug | +| Info | Info | info | +| Warn | Warning | warn | +| Error | Error | error | +| Fatal | Fatal | fatal | + +These properties will be sent to Sentry, and can be searched from within the Logs UI, and even added to the Logs views as a dedicated column. + +```csharp +var logger = LogManager.GetCurrentClassLogger(); + +logger.Info("A simple log message"); +logger.Error("A {Parameter} log message", "formatted"); +logger.WithProperty("Property", "Value").Warn("Message with Property"); +``` + +The _properties_ of _log events_ are attached as 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 SDK automatically provides a set of default attributes attached to your logs. Additionally, you can attach custom attributes via a delegate. From 20bab9053860ea8df05c3b2f2d258e1d021d0dd9 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 16 Jul 2026 12:00:35 +1200 Subject: [PATCH 2/2] Apply suggestion from @jamescrosswell --- platform-includes/logs/requirements/dotnet.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/logs/requirements/dotnet.mdx b/platform-includes/logs/requirements/dotnet.mdx index 19058c96110b08..5568eff0f1b25a 100644 --- a/platform-includes/logs/requirements/dotnet.mdx +++ b/platform-includes/logs/requirements/dotnet.mdx @@ -7,5 +7,5 @@ Logs for are supported in Sentry S -Logs for are supported in Sentry SDK version `6.7.0` and above. +Logs for are supported in Sentry SDK version `6.8.0` and above.