Fluent.Unions.Serilog
1.1.0
dotnet add package Fluent.Unions.Serilog --version 1.1.0
NuGet\Install-Package Fluent.Unions.Serilog -Version 1.1.0
<PackageReference Include="Fluent.Unions.Serilog" Version="1.1.0" />
<PackageVersion Include="Fluent.Unions.Serilog" Version="1.1.0" />
<PackageReference Include="Fluent.Unions.Serilog" />
paket add Fluent.Unions.Serilog --version 1.1.0
#r "nuget: Fluent.Unions.Serilog, 1.1.0"
#:package Fluent.Unions.Serilog@1.1.0
#addin nuget:?package=Fluent.Unions.Serilog&version=1.1.0
#tool nuget:?package=Fluent.Unions.Serilog&version=1.1.0
![]()
Fluent.Unions.Serilog
Logs Result, Result<T>, your own result types, Option<T> and Loadable<T> as structured values instead of opaque objects. It builds on Fluent.Unions and Serilog.
Installation
dotnet add package Fluent.Unions.Serilog
Usage
Register the destructuring policy, then destructure with @.
using Serilog;
using Fluent.Unions.Serilog;
Log.Logger = new LoggerConfiguration()
.Destructure.WithFluentUnions()
.WriteTo.Console()
.CreateLogger();
Log.Information("Nickname {@Nickname}", Option.Some("Countess")); // Nickname "Countess"
Log.Information("Nickname {@Nickname}", (Option<string>)Option.None); // Nickname null
Log.Information("Order {@Order}", LoadOrder(id));
// Order { Id: 42 } for a value, Order { Error: { Type: "System.TimeoutException", Message: "Slow" } } for an error
A value is logged as itself and an error as { Error: { Type, Message } }. The stack trace is never logged. Pass the exception to the log call to put it in the log event's exception slot: Log.Error(result.GetError(), "Load failed").
With your own result type
.Destructure.WithFluentUnions() destructures any result type, including one declared with [FluentResult<TError>], like the default ones. A value-less success logs "Ok". See Your own Result type.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Fluent.Unions (>= 1.1.0)
- Serilog (>= 4.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.