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
1 change: 0 additions & 1 deletion docs/platforms/dotnet/common/logs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sidebar_order: 2
sidebar_section: features
notSupported:
- dotnet.google-cloud-functions
- dotnet.nlog
- dotnet.xamarin
---

Expand Down
5 changes: 4 additions & 1 deletion docs/platforms/dotnet/guides/nlog/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand All @@ -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:
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 @@ -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"
/>
- <LinkWithPlatformIcon
platform="dotnet.nlog"
label="NLog"
url="/platforms/dotnet/guides/nlog/logs/"
skill="sentry-dotnet-sdk"
/>
- <LinkWithPlatformIcon
platform="dotnet.log4net"
label="log4net"
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 @@ -4,6 +4,7 @@ Available integrations:
<IntegrationListItem href="/platforms/dotnet/guides/maui/logs/">.NET Multi-platform App UI (.NET MAUI)</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>
<IntegrationListItem href="/platforms/dotnet/guides/log4net/logs/">log4net</IntegrationListItem>
</ul>

Expand Down
6 changes: 5 additions & 1 deletion platform-includes/logs/options/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#### EnableLogs

<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.log4net"]}>
<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.nlog", "dotnet.log4net"]}>
Set to `true` in order to enable the `SentrySdk.Logger` APIs.
</PlatformSection>

Expand All @@ -12,6 +12,10 @@ Set to `true` in order to enable the logging integration via the `ILogger<TCateg
Set to `true` in order to enable the logging integration via the `Log`/`Logger` APIs.
</PlatformSection>

<PlatformSection supported={["dotnet.nlog"]}>
Set to `true` in order to enable the logging integration via the NLog `Logger` APIs.
</PlatformSection>

<PlatformSection supported={["dotnet.log4net"]}>
Set to `true` in order to enable the logging integration via the log4net `ILog` APIs.
</PlatformSection>
Expand Down
6 changes: 5 additions & 1 deletion platform-includes/logs/requirements/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<PlatformSection notSupported={["dotnet.serilog", "dotnet.log4net"]}>
<PlatformSection notSupported={["dotnet.serilog", "dotnet.nlog", "dotnet.log4net"]}>
Logs for <PlatformOrGuideName/> are supported in Sentry <PlatformOrGuideName/> SDK version `5.14.0` and above.
</PlatformSection>

<PlatformSection supported={["dotnet.serilog"]}>
Logs for <PlatformOrGuideName/> are supported in Sentry <PlatformOrGuideName/> SDK version `5.16.0` and above.
</PlatformSection>

<PlatformSection supported={["dotnet.nlog"]}>
Logs for <PlatformOrGuideName/> are supported in Sentry <PlatformOrGuideName/> SDK version `6.8.0` and above.
</PlatformSection>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The documentation uses a placeholder version 6.8.0 for a feature. This version is not final and will be incorrect if merged as-is, causing user confusion.
Severity: MEDIUM

Suggested Fix

Before merging, update the placeholder version 6.8.0 in platform-includes/logs/requirements/dotnet.mdx to the correct, released version of the Sentry .NET SDK that includes the feature. This ensures the documentation provides accurate requirements to users.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: platform-includes/logs/requirements/dotnet.mdx#L12

Potential issue: The documentation introduces a placeholder version `6.8.0` for NLog
structured logs support. While the PR author has noted this is a temporary value and the
PR should only be merged after the actual SDK version is determined, there are no
automated CI checks or technical gates to prevent a premature merge. If this PR is
merged before the placeholder is updated, users will be given incorrect information
about the minimum required SDK version, leading to confusion and failed attempts to use
the feature.

Did we get this right? 👍 / 👎 to inform future reviews.

<PlatformSection supported={["dotnet.log4net"]}>
Logs for <PlatformOrGuideName/> are supported in Sentry <PlatformOrGuideName/> SDK version `6.8.0` and above.
</PlatformSection>
19 changes: 18 additions & 1 deletion platform-includes/logs/setup/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
To enable logging, you need to initialize the SDK with the `EnableLogs` option set to `true`.

<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.aws-lambda", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.log4net"]}>
<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.aws-lambda", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.nlog", "dotnet.log4net"]}>

```csharp
SentrySdk.Init(options =>
Expand Down Expand Up @@ -70,6 +70,23 @@ This enables the `SentrySdk.Logger` APIs, as well as the `Microsoft.Extensions.L
```


</PlatformSection>

<PlatformSection supported={["dotnet.nlog"]}>

```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.

</PlatformSection>

<PlatformSection supported={["dotnet.log4net"]}>
Expand Down
33 changes: 31 additions & 2 deletions platform-includes/logs/usage/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.log4net"]}>
<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.nlog", "dotnet.log4net"]}>

Once the feature is enabled on the SDK and the SDK is initialized, you can send logs using the `SentrySdk.Logger` APIs.

Expand Down Expand Up @@ -81,6 +81,35 @@ The _Enrichments_ of _log events_ are attached as attributes to the logs, alongs

</PlatformSection>

<PlatformSection supported={["dotnet.nlog"]}>

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.

</PlatformSection>

<PlatformSection supported={["dotnet.log4net"]}>

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`).
Expand Down Expand Up @@ -116,7 +145,7 @@ Because log4net renders each message before it reaches the appender, structured

</PlatformSection>

<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.log4net"]}>
<PlatformSection notSupported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui", "dotnet.serilog", "dotnet.nlog", "dotnet.log4net"]}>

The SDK automatically provides a set of default attributes attached to your logs.
Additionally, you can attach custom attributes via a delegate.
Expand Down
Loading