A Sentry sink for Serilog
Clone or download
Latest commit 711daa2 Nov 17, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
demos feature: Header, cookie, data, etc. scrubbing (#17) Nov 11, 2018
src Update version Nov 16, 2018
.gitignore Update build definition Sep 24, 2018
LICENSE Initial commit Aug 26, 2017
README.md feature: Header, cookie, data, etc. scrubbing (#17) Nov 11, 2018
appveyor.yml Remove tools folder Sep 24, 2018
build.cake Remove tools folder Sep 24, 2018



Build status Quality Gate

Serilog.Sinks.Sentry NuGet
Serilog.Sinks.Sentry.AspNetCore NuGet

A Sentry sink for Serilog.


The library is available as a Nuget package.

Install-Package Serilog.Sinks.Sentry


You can find demo .NET Core apps here.

Get started

Adding Sentry sink

var log = new LoggerConfiguration()
    .WriteTo.Sentry("Sentry DSN")

// By default, only messages with level errors and higher are captured
log.Error("This error goes to Sentry.");

Data scrubbing

Some of the logged content might contain sensitive data and should therefore not be sent to Sentry. When setting up the Sentry Sink it is possible to provide a custom IScrubber implementation which will be passed the serialized data that is about to be sent to Sentry for scrubbing / cleaning.

Adding a scrubber would look like this:

var log = new LoggerConfiguration()
    .WriteTo.Sentry("Sentry DSN", dataScrubber: new MyDataScrubber())

MyDataScrubber has to implement the interface SharpRaven.Logging.IScrubber. Check the Web Demo Startup.cs for further details and the example implementation of a scrubber .

Capturing HttpContext (ASP.NET Core)

In order to capture a user, request body and headers, some additional steps are required.

Install the additional sink for ASP.NET Core

Install-Package Serilog.Sinks.Sentry.AspNetCore

Specify custom HttpContext destructing policy

var log = new LoggerConfiguration()
    .WriteTo.Sentry("Sentry DSN")

    // Add this two lines to the logger configuration
    .Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true)


Add Sentry context middleware in Startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    // Add this line

    // Other stuff