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
<PackageReference Include="Sstv.DomainExceptions.Extensions.SerilogEnricher" Version="3.0.0" />
paket add Sstv.DomainExceptions.Extensions.SerilogEnricher --version 3.0.0
#r "nuget: Sstv.DomainExceptions.Extensions.SerilogEnricher, 3.0.0"
// 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
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. |
-
net9.0
- Serilog (>= 4.1.0)
- Sstv.DomainExceptions (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.