diff --git a/docs/platforms/dotnet/common/logs/index.mdx b/docs/platforms/dotnet/common/logs/index.mdx index 63fd1a0541f7e..f52dbdb5a39db 100644 --- a/docs/platforms/dotnet/common/logs/index.mdx +++ b/docs/platforms/dotnet/common/logs/index.mdx @@ -6,7 +6,6 @@ sidebar_order: 2 sidebar_section: features notSupported: - dotnet.google-cloud-functions - - dotnet.nlog - dotnet.xamarin --- diff --git a/docs/platforms/dotnet/guides/nlog/index.mdx b/docs/platforms/dotnet/guides/nlog/index.mdx index 1e4fae1abe5a7..0a840be059cde 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 13c80f4ea1836..cadc0297f3de3 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" /> +- - .NET Multi-platform App UI (.NET MAUI) Microsoft.Extensions.Logging Serilog +NLog log4net diff --git a/platform-includes/logs/options/dotnet.mdx b/platform-includes/logs/options/dotnet.mdx index ce8093d0b4460..109b4499fbb3b 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. + + Set to `true` in order to enable the logging integration via the log4net `ILog` APIs. diff --git a/platform-includes/logs/requirements/dotnet.mdx b/platform-includes/logs/requirements/dotnet.mdx index b0c0e77ea0a79..33859401902c3 100644 --- a/platform-includes/logs/requirements/dotnet.mdx +++ b/platform-includes/logs/requirements/dotnet.mdx @@ -1,4 +1,4 @@ - + Logs for are supported in Sentry SDK version `5.14.0` and above. @@ -6,6 +6,10 @@ Logs for are supported in Sentry S Logs for are supported in Sentry SDK version `5.16.0` and above. + +Logs for are supported in Sentry SDK version `6.8.0` and above. + + Logs for are supported in Sentry SDK version `6.8.0` and above. diff --git a/platform-includes/logs/setup/dotnet.mdx b/platform-includes/logs/setup/dotnet.mdx index d82b0998bb6cf..4757af348c62e 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. + diff --git a/platform-includes/logs/usage/dotnet.mdx b/platform-includes/logs/usage/dotnet.mdx index 6a481c086217a..9136ca9004002 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,6 +81,35 @@ 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. + + + 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`). @@ -116,7 +145,7 @@ Because log4net renders each message before it reaches the appender, structured - + The SDK automatically provides a set of default attributes attached to your logs. Additionally, you can attach custom attributes via a delegate.