Sstv.DomainExceptions.Extensions.SerilogEnricher 3.0.0

dotnet add package Sstv.DomainExceptions.Extensions.SerilogEnricher --version 3.0.0                
NuGet\Install-Package Sstv.DomainExceptions.Extensions.SerilogEnricher -Version 3.0.0                
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="Sstv.DomainExceptions.Extensions.SerilogEnricher" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sstv.DomainExceptions.Extensions.SerilogEnricher --version 3.0.0                
#r "nuget: Sstv.DomainExceptions.Extensions.SerilogEnricher, 3.0.0"                
#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 Sstv.DomainExceptions.Extensions.SerilogEnricher as a Cake Addin
#addin nuget:?package=Sstv.DomainExceptions.Extensions.SerilogEnricher&version=3.0.0

// Install Sstv.DomainExceptions.Extensions.SerilogEnricher as a Cake Tool
#tool nuget:?package=Sstv.DomainExceptions.Extensions.SerilogEnricher&version=3.0.0                

Sstv.DomainExceptions.Extensions.SerilogEnricher

<- root readme

<- changelog

This library integrates Sstv.DomainExceptions with Serilog using it's enrich feature. When you write to log, serilog can attach some extra data to you logging message. So when exception logged, we can add an error code and user provided additional data from exception instance to the current logging scope.

Install

You can install using Nuget Package Manager:

Install-Package Sstv.DomainExceptions.Extensions.SerilogEnricher -Version 3.0.0

via the .NET CLI:

dotnet add package Sstv.DomainExceptions.Extensions.SerilogEnricher --version 3.0.0

or you can add package reference manually:

<PackageReference Include="Sstv.DomainExceptions.Extensions.SerilogEnricher" Version="3.0.0" />

How to use?

When you configuring your Serilog logger, add enricher via method WithDomainException e.g.:

 public static class HostBuilderExtensions
 {
     public static IHostBuilder UseSerilog(this IHostBuilder hostBuilder)
     {
         return hostBuilder.UseSerilog((hostingContext, loggerConfiguration) =>
         {
             var serviceName = hostingContext.Configuration.GetValue<string>("ServiceName");
             var hostName = hostingContext.Configuration.GetValue<string>("HOSTNAME");

             loggerConfiguration
                 .MinimumLevel.Information()
                 .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
                 .MinimumLevel.Override("System", LogEventLevel.Warning)
                 .Enrich.WithProperty("Service", serviceName)
                 .Enrich.WithProperty("Host", hostName)
+                .Enrich.WithDomainException()
                 .WriteTo.Console();
         });
     }
 }
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible. 
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
3.0.0 94 12/5/2024
2.3.0 75 12/6/2024
2.2.0 148 2/18/2024
2.1.1 112 2/14/2024
2.1.0 131 2/12/2024
1.0.0 157 10/4/2023