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
6 changes: 4 additions & 2 deletions platform-includes/logs/options/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#### EnableLogs

<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.
Set to `true` to send logs captured by logging integrations, such as `Microsoft.Extensions.Logging`, Serilog, NLog, and log4net. 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.
</PlatformSection>

<PlatformSection supported={["dotnet.aspnetcore", "dotnet.azure-functions-worker", "dotnet.blazor-webassembly", "dotnet.extensions-logging", "dotnet.maui"]}>
Expand Down Expand Up @@ -47,7 +49,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, while `EnableLogs = true` keeps the `SentrySdk.Logger` APIs available.
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`:

Expand Down
9 changes: 3 additions & 6 deletions platform-includes/logs/setup/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
To enable logging, you need to 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. To send logs captured by logging integrations, 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.nlog", "dotnet.log4net"]}>

Comment thread
sentry[bot] marked this conversation as resolved.
```csharp
SentrySdk.Init(options =>
{
options.Dsn = "___PUBLIC_DSN___";
// Enable logs to be sent to Sentry
options.EnableLogs = true;
});
```


This enables the `SentrySdk.Logger` APIs.
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.

</PlatformSection>

Comment thread
sentry[bot] marked this conversation as resolved.
Expand All @@ -28,7 +25,7 @@ This enables the `SentrySdk.Logger` APIs.
```


This enables the `SentrySdk.Logger` APIs, as well as the `Microsoft.Extensions.Logging` integration.
This enables the `Microsoft.Extensions.Logging` integration. The `SentrySdk.Logger` APIs don't depend on `EnableLogs`.

</PlatformSection>

Expand Down
2 changes: 1 addition & 1 deletion platform-includes/logs/usage/dotnet.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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.
Once the SDK is initialized, you can send logs using the `SentrySdk.Logger` APIs.

The `SentryStructuredLogger` type exposes six method groups that you can use to log messages at different log levels: `Trace`, `Debug`, `Info`, `Warning`, `Error`, and `Fatal`.

Expand Down
Loading