Oakrey.Log.Sanitizers 3.0.0

dotnet add package Oakrey.Log.Sanitizers --version 3.0.0
                    
NuGet\Install-Package Oakrey.Log.Sanitizers -Version 3.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="Oakrey.Log.Sanitizers" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Log.Sanitizers" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Log.Sanitizers" />
                    
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 Oakrey.Log.Sanitizers --version 3.0.0
                    
#r "nuget: Oakrey.Log.Sanitizers, 3.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 Oakrey.Log.Sanitizers@3.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=Oakrey.Log.Sanitizers&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Log.Sanitizers&version=3.0.0
                    
Install as a Cake Tool

Oakrey.Log.Sanitizers

1. Overview

The "Log.Sanitizers" project provides optional secret sanitizers for Oakrey logging packages. It is intentionally separated from Oakrey.Log.Abstractions so applications that do not need cyber-security oriented log redaction can keep the default empty sanitizer and avoid regex-based overhead.

2. Features

Secret Sanitization:

  • DefaultSecretSanitizer: Redacts common secret-like values before entries reach any logger sink.
  • SecretSanitizationOptions: Configures replacement text, pattern timeout, and additional custom patterns.
  • SecretSanitizationPattern: Adds custom regex-based redaction rules.

Built-in Rules:

  • Password and token assignments such as password=..., apiKey=..., and access_token=....
  • Authorization bearer values.
  • Connection string passwords.
  • JWT-like values.
  • PEM private key blocks.

3. Installation

You can install the package via NuGet Package Manager, Package Manager Console or the .NET CLI.

.NET CLI

Run the following command in your terminal:

dotnet add package Oakrey.Log.Sanitizers

Package Manager Console

Run the following command in your Package Manager Console:

Install-Package Oakrey.Log.Sanitizers

4. Usage

Oakrey.Log.Abstractions uses EmptyLogSecretSanitizer by default. Enable secret redaction explicitly when the application needs it:

LoggerFactory.SetSecretSanitizer(new DefaultSecretSanitizer());

You can customize the sanitizer:

LoggerFactory.SetSecretSanitizer(new DefaultSecretSanitizer(new SecretSanitizationOptions
{
    ReplacementText = "[SECRET REMOVED]"
}));

Additional rules can be added through custom patterns:

SecretSanitizationOptions options = new();
options.AdditionalPatterns.Add(new SecretSanitizationPattern("CustomSecret", @"custom-secret-\d+"));
LoggerFactory.SetSecretSanitizer(new DefaultSecretSanitizer(options));

5. Requirements

  • .NET 10 or higher

6. Project Information

7. Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the package.

8. License

This project is licensed under the MIT License. See the LICENSE file for details.

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
3.0.0 124 7/10/2026