Serilog.Sinks.SentrySDK
1.0.7.2
dotnet add package Serilog.Sinks.SentrySDK --version 1.0.7.2
NuGet\Install-Package Serilog.Sinks.SentrySDK -Version 1.0.7.2
<PackageReference Include="Serilog.Sinks.SentrySDK" Version="1.0.7.2" />
<PackageVersion Include="Serilog.Sinks.SentrySDK" Version="1.0.7.2" />
<PackageReference Include="Serilog.Sinks.SentrySDK" />
paket add Serilog.Sinks.SentrySDK --version 1.0.7.2
#r "nuget: Serilog.Sinks.SentrySDK, 1.0.7.2"
#:package Serilog.Sinks.SentrySDK@1.0.7.2
#addin nuget:?package=Serilog.Sinks.SentrySDK&version=1.0.7.2
#tool nuget:?package=Serilog.Sinks.SentrySDK&version=1.0.7.2
Serilog.Sinks.SentrySDK
A Serilog sink for Sentry that simplifies error and log management in your applications. It builds on the Sentry .NET SDK and official Serilog integration.
Based on serilog-contrib/serilog-sinks-sentry
Project status
Available packages
Release 1.0.7.2 on NuGet aligns with GitHub tags such as v1.0.7.2. GitHub Releases carry the changelog and attached .nupkg assets.
| Package | When to use |
|---|---|
| Serilog.Sinks.SentrySDK | Core sink; net6.0 and net10.0 in one package (lib/net6.0/, lib/net10.0/). |
| Serilog.Sinks.SentrySDK.AspNetCore | HTTP context integration and middleware; net6.0 + net10.0. |
| Serilog.Sinks.SentrySDK.6 / Serilog.Sinks.SentrySDK.AspNetCore.6 | Same sink and ASP.NET Core extras; net6.0-only package ids. |
| Serilog.Sinks.SentrySDK.10 / Serilog.Sinks.SentrySDK.AspNetCore.10 | Same functionality; net10.0-only package ids. |
Prefer the main ids unless you want a single target framework per NuGet package id.
Installation
Core sink:
dotnet add package Serilog.Sinks.SentrySDK
Install-Package Serilog.Sinks.SentrySDK
ASP.NET Core companion (user/request context in logs):
dotnet add package Serilog.Sinks.SentrySDK.AspNetCore
Install-Package Serilog.Sinks.SentrySDK.AspNetCore
Alternate ids (single TFM per package): Serilog.Sinks.SentrySDK.6, Serilog.Sinks.SentrySDK.10, and matching AspNetCore ids — see Available packages.
This stack references the Sentry NuGet package (6.3.2), the same major line as Sentry for .NET. For DSN, SendDefaultPii, and debug options, see the Quick Start. Initialize as early as possible so startup failures are reported. This sink calls SentrySdk.Init when you configure WriteTo.Sentry with a DSN; avoid a second SentrySdk.Init in the same process unless you deliberately use one initialization path.
Set a valid Sentry DSN in appsettings.json or in code. Without a DSN, the sink throws when the DSN argument is empty. Demos show JSON and programmatic configuration.
Getting started
Add the sink so logs are sent to Sentry. You can use Serilog.Settings.Configuration with JSON:
{
"Serilog": {
"Using": [ "Serilog.Sinks.SentrySDK" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "Sentry",
"Args": {
"dsn": "YOUR_SENTRY_DSN",
"sendDefaultPii": true,
"environment": "Development",
"release": "1.0.7.2",
"attachStacktrace": true,
"tracesSampleRate": 1.0
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Sample"
}
}
}
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();
var log = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.Enrich.FromLogContext()
.CreateLogger();
log.Error("This error goes to Sentry.");
Optional configureSentryOptions and beforeSend on WriteTo.Sentry map to init-time SentryOptions and a chained SetBeforeSend. A fuller argument list and examples are in the repository README — Getting Started.
Data scrubbing
Use SetBeforeSend / SetBeforeSendTransaction on SentryOptions for client-side scrubbing; see Scrubbing sensitive data. Prefer the sink’s optional beforeSend callback for event filtering; use configureSentryOptions for other flags (for example EnableLogs, EnableMetrics) and do not call SetBeforeSend inside that callback, because the sink registers its own SetBeforeSend chain. You can still use Serilog filters and enrichers to limit what reaches the sink.
Capturing HttpContext (ASP.NET Core)
Install Serilog.Sinks.SentrySDK.AspNetCore, then extend the logger:
var log = new LoggerConfiguration()
.WriteTo.Sentry("YOUR_SENTRY_DSN")
.Enrich.FromLogContext()
.Destructure.With<HttpContextDestructingPolicy>()
.Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true)
.CreateLogger();
Register middleware (for example in Startup / pipeline setup):
app.AddSentryContext();
Full snippets, including older Startup.cs examples, are in the repository README — Capturing HttpContext.
Sentry SDK options vs this sink
This package aligns with Sentry .NET 6.3.2. The repository README maps SentryOptions properties and methods to WriteTo.Sentry parameters (large tables): Sentry SDK and Mapping to WriteTo.Sentry.
Further reading: Data Management, Structured logs, Migration guide.
Demos, build, contributing
- Demos: demos/README.md on GitHub
- Solution and local build/test commands: README — Build, run tests, and coverage
- CONTRIBUTING.md
Full documentation (CI, publishing, formatting): README.md on GitHub.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Newtonsoft.Json (>= 13.0.4)
- Sentry (>= 6.3.2)
- Sentry.Serilog (>= 6.3.2)
- Serilog (>= 4.3.1)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Settings.Configuration (>= 10.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.Sentry (>= 2.4.3)
-
net6.0
- Newtonsoft.Json (>= 13.0.4)
- Sentry (>= 6.3.2)
- Sentry.Serilog (>= 6.3.2)
- Serilog (>= 4.3.1)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Settings.Configuration (>= 10.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.Sentry (>= 2.4.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.7.2: includes net6.0 and net10.0. Release notes: https://github.com/antoinebou12/Serilog.Sinks.SentrySDK/releases