Sharpbrake.Serilog 1.0.8

dotnet add package Sharpbrake.Serilog --version 1.0.8                
NuGet\Install-Package Sharpbrake.Serilog -Version 1.0.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sharpbrake.Serilog" Version="1.0.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sharpbrake.Serilog --version 1.0.8                
#r "nuget: Sharpbrake.Serilog, 1.0.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sharpbrake.Serilog as a Cake Addin
#addin nuget:?package=Sharpbrake.Serilog&version=1.0.8

// Install Sharpbrake.Serilog as a Cake Tool
#tool nuget:?package=Sharpbrake.Serilog&version=1.0.8                

Sharpbrake.Serilog

NuGet

A Serilog sink that sends log records to Airbrake.

Airbrake sink

In the example shown, the sink will send logs to Airbrake with a minimum log level of LogEventLevel.Fatal. The Sharpbrake.Serilog Sink also supports more flexible Airbrake customization using the AirbrakeConfig class.

Log.Logger = new LoggerConfiguration()
    .WriteTo.Airbrake(projectId: "<projectId>", projectKey: "<projectKey>", LogEventLevel.Fatal)
    .CreateLogger();

StackTraceCapturer sink

This sink allows you to use stack capturing when it's needed, for example when you want to use Async sink while keeping the original stack trace. This is how you use it:

var config = new Sharpbrake.Client.AirbrakeConfig
{...};
 
var config = new LoggerConfiguration()
    .WriteTo
    .StackTraceCapturer(w => w.Async(x => x.Airbrake(config, LogEventLevel.Fatal)));

Log.Logger = config.CreateLogger();

In the code above the StackTraceCapturer is added and it wraps other sink - Async which in turn wraps our Airbrake sink described above - this way you can notify Airbrake in an async manner while keeping the original stack traces.

Additional filtering

You can specify additional filtering for the Airbrake sink. This might be useful when you want to avoid some messages going to Airbrake or deduplicate similar messages (anti-flood).

var config = new Sharpbrake.Client.AirbrakeConfig
{...};
 
var config = new LoggerConfiguration()
    .WriteTo.Airbrake(config, LogEventLevel.Fatal, new AibrakeThrottlingFilter())
    .CreateLogger();

where AibrakeThrottlingFilter looks like this:

class AibrakeThrottlingFilter : Sharpbrake.Serilog.ILoggerFilter
    {
        // The main filtering routine
        // returning null means 'don't send'
        public LogEvent Filter(LogEvent logEvent)
        {
            return null; // don't send to Airbrake
        }

        // Airbrake sink will give a 'sender' to the object
        // to allow it to send notifications later
        public void SetNoticeSender(Action<LogEvent> sendAction)
        {
            // this is the sender we can use to send message later
        }
    }

You can build any logic that you want to on top of this interface and use sendAction to send custom messages at any point in time.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.8 38,446 11/16/2021
1.0.7 677 10/15/2021
1.0.6 537 8/6/2021
1.0.5 372 4/14/2021

A Serilog sink that send logs to airbrake.