Serilog.Destructure.NamedValuesHandler 0.0.2-alpha

This is a prerelease version of Serilog.Destructure.NamedValuesHandler.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Serilog.Destructure.NamedValuesHandler --version 0.0.2-alpha                
NuGet\Install-Package Serilog.Destructure.NamedValuesHandler -Version 0.0.2-alpha                
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="Serilog.Destructure.NamedValuesHandler" Version="0.0.2-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Destructure.NamedValuesHandler --version 0.0.2-alpha                
#r "nuget: Serilog.Destructure.NamedValuesHandler, 0.0.2-alpha"                
#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 Serilog.Destructure.NamedValuesHandler as a Cake Addin
#addin nuget:?package=Serilog.Destructure.NamedValuesHandler&version=0.0.2-alpha&prerelease

// Install Serilog.Destructure.NamedValuesHandler as a Cake Tool
#tool nuget:?package=Serilog.Destructure.NamedValuesHandler&version=0.0.2-alpha&prerelease                

Serilog.Destructure.NamedValuesHandler

GitHub Workflow Status (branch) Nuget

Work In Progress. No guaranties.

Handles values of structured logs. Can mask or omit values from structured logs

ToDos

  • Cover with tests all possible use cases
  • Add more examples and use-cases
  • Resolve todos in code

Typical Usage

  • Mask some sensitive values:

    var logger = new LoggerConfiguration()
        .Destructure
            .HandleValues(p => p
                .MaskStringValue("email")                           // *********
                .MaskStringValue("IBAN", visibleCharsAmount: 6)     // **********************560101
            )
        .CreateLogger();
    
  • Completely remove some values:

        var logger = new LoggerConfiguration()
            .Destructure
                .HandleValues(p => p
                    .OmitNames("email", "IBAN")
                    .OmitFromNamespace("Business.Domain.Secured", "System")
                    .OmitOfType(typeof(DestructibleEntity))
                )
            .CreateLogger();
    
  • Do your own value modification:

    var logger = new LoggerConfiguration()
                  .Destructure
                  .HandleValues(p => p
                      .WithNamedValueHandler(
                          "email",
                          (value, type) => $"*****@{value.Split("@").Last()}")) // *****@gmail.com
                  .CreateLogger();
    
  • Omit by your own rules:

    var logger = new LoggerConfiguration()
        .Destructure
        .HandleValues(p => p
            .WithOmitHandler(
                (name, value, type) => name == "age" && (int)value < 18))
        .CreateLogger();
    
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
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
0.2.0-alpha 229 9/16/2021
0.1.0-alpha 232 9/12/2021
0.0.2-alpha 236 9/11/2021
0.0.1-alpha 222 9/11/2021

Early development phase