Sstv.DomainExceptions.Extensions.SerilogEnricher
2.2.0
dotnet add package Sstv.DomainExceptions.Extensions.SerilogEnricher --version 2.2.0
NuGet\Install-Package Sstv.DomainExceptions.Extensions.SerilogEnricher -Version 2.2.0
<PackageReference Include="Sstv.DomainExceptions.Extensions.SerilogEnricher" Version="2.2.0" />
paket add Sstv.DomainExceptions.Extensions.SerilogEnricher --version 2.2.0
#r "nuget: Sstv.DomainExceptions.Extensions.SerilogEnricher, 2.2.0"
// Install Sstv.DomainExceptions.Extensions.SerilogEnricher as a Cake Addin #addin nuget:?package=Sstv.DomainExceptions.Extensions.SerilogEnricher&version=2.2.0 // Install Sstv.DomainExceptions.Extensions.SerilogEnricher as a Cake Tool #tool nuget:?package=Sstv.DomainExceptions.Extensions.SerilogEnricher&version=2.2.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 2.2.0
via the .NET CLI:
dotnet add package Sstv.DomainExceptions.Extensions.SerilogEnricher --version 2.2.0
or you can add package reference manually:
<PackageReference Include="Sstv.DomainExceptions.Extensions.SerilogEnricher" Version="2.2.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 | 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. |
-
net6.0
- Serilog (>= 3.1.1)
- Sstv.DomainExceptions (>= 2.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.