CodoMetis.TypeKit.Serilog 2.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package CodoMetis.TypeKit.Serilog --version 2.0.0
                    
NuGet\Install-Package CodoMetis.TypeKit.Serilog -Version 2.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="CodoMetis.TypeKit.Serilog" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CodoMetis.TypeKit.Serilog" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="CodoMetis.TypeKit.Serilog" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CodoMetis.TypeKit.Serilog --version 2.0.0
                    
#r "nuget: CodoMetis.TypeKit.Serilog, 2.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.
#:package CodoMetis.TypeKit.Serilog@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CodoMetis.TypeKit.Serilog&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=CodoMetis.TypeKit.Serilog&version=2.0.0
                    
Install as a Cake Tool

CodoMetis.TypeKit.Serilog

Serilog integration for CodoMetis.TypeKit value objects and closed sets: each is logged as what it prints, also where Serilog destructures it.

dotnet add package CodoMetis.TypeKit.Serilog

It needs Serilog 4.0.0 or later.

using Serilog;

using var logger = new LoggerConfiguration()
    .Destructure.WithTypeKit()
    .WriteTo.Console()
    .CreateLogger();

logger.Information("Created {@Client}", new Client(ApiKey.From("k-123"), "Ann"));   // Created {"Key": "ApiKey(***)", "Name": "Ann", "$type": "Client"}
  • Why. Serilog destructures an object ({@Key}, or a record holding one) by reading its public properties, and a value object's Value is public: without this, a value object that masks itself with a hand-written ToString() is logged unmasked there, as { Value: "k-123" }, and nowhere else. With it, Serilog logs value objects as Microsoft.Extensions.Logging does, as their text.
  • Every value object, masked or not, is then a string in the event: an OrderId is "0199aaaa-…", not { Value: "0199aaaa-…" }, and a Quantity is "3". A list or dictionary of them is a list or dictionary of strings.
  • A closed set is logged as its name, or as what its own ToString() prints, never by its properties: {@Order} holds Status: "Shipped", not the set's constant data. An instance the set's own code made beside its members has no name, and Serilog logs that it could not capture it.
  • Nothing per type. A value object or a closed set is recognised by the attribute the generators put on it, so the host needs this package and the base package, not the generators. Other types are left to Serilog.
  • To mask a value object, declare ToString(); the Generators README says what else then still carries the value.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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
2.2.0 144 10/18/2026
2.1.0 1,207 10/15/2026
2.0.0 159 10/14/2026
1.5.1 116 10/11/2026
1.5.0 97 10/11/2026