Cerbi.Serilog.GovernanceAnalyzer 1.1.2

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

Cerbi.Serilog.Governance

๐Ÿ”’ Real-time governance enforcement for Serilog using Cerbi โ€” the structured logging validator for modern .NET systems.


๐Ÿš€ What It Does

Cerbi helps enforce logging safety, structure, and compliance in real time.

๐Ÿ“ Enforces required/forbidden fields ๐Ÿ”’ Blocks logs with unsafe values ๐Ÿ›๏ธ Validates enums and field types ๐Ÿšง Supports relaxed logging bypass (logger.Relax()) ๐Ÿ“ˆ Enriches logs with governance tags (optional) ๐Ÿ” Works with any Serilog sink (Console, File, Seq, etc.)


๐Ÿ“† NuGet Packages


โšก Quick Start

1๏ธโƒฃ Install the Serilog plugin

dotnet add package Cerbi.Serilog.Governance

2๏ธโƒฃ Create cerbi_governance.json

{
  "EnforcementMode": "Strict",
  "LoggingProfiles": {
    "Orders": {
      "RequireTopic": false,
      "AllowedTopics": ["Orders", "Users"],
      "FieldSeverities": {
        "userId": "Required",
        "email": "Required",
        "password": "Forbidden"
      },
      "FieldEnums": {
        "Status": ["Pending", "Approved", "Rejected"]
      },
      "AllowRelax": true
    }
  }
}

3๏ธโƒฃ Configure Serilog with Cerbi filtering

using Cerbi.Serilog.Governance;

Log.Logger = new LoggerConfiguration()
    .Filter.WithCerbiGovernanceFiltering(options =>
    {
        options.Profile = "Orders";
        options.ConfigPath = "cerbi_governance.json";
    })
    .WriteTo.Console()
    .CreateLogger();

๐Ÿ“ Example Log Calls

โœ… Valid Log

logger
    .ForContext("userId", "abc123")
    .ForContext("email", "user@example.com")
    .ForContext("Status", "Approved")
    .Information("Order submitted");

โŒ Missing Required Field (blocked)

logger
    .ForContext("email", "user@example.com")
    .Information("Missing userId");

โŒ Forbidden Field (blocked)

logger
    .ForContext("userId", "abc123")
    .ForContext("email", "user@example.com")
    .ForContext("password", "supersecret")
    .Information("Attempted login");

๐Ÿงช Relaxed Logging (bypass)

logger
    .Relax()
    .ForContext("email", "test@example.com")
    .Information("Non-compliant, but allowed in Relax mode");

Relaxed logs are not blocked, but are tagged as GovernanceRelaxed: true.


๐Ÿ“ค Console Output Example

{
  "userId": "abc123",
  "email": "user@example.com",
  "Status": "Approved"
}

If enriched with governance:

{
  "GovernanceProfileUsed": "Orders",
  "GovernanceViolations": [],
  "GovernanceRelaxed": false
}

๐Ÿง Notes

  • [CerbiTopic] support is planned once the runtime exposes Validate(..., callerType) or Evaluate(...).
  • Use .Enrich.WithCerbiGovernanceTagging(...) if you want to annotate logs without filtering them.

๐Ÿ“Œ See Also


๐Ÿ’ผ Why Use CerbiStream?

While Cerbi.Serilog.Governance adds runtime enforcement to Serilog, CerbiStream offers:

  • Built-in support for governance decorators like [CerbiTopic("...")]
  • Source generator + analyzer enforcement for compile-time rules
  • Flexible multi-sink fallback (file, blob, queue)
  • Real-time enforcement + tagging built into logger API

Use CerbiStream if you want governance baked directly into your logging library with rich metadata routing and enterprise compliance controls.


Made with โค๏ธ by Cerbi

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.1.2 142 5/26/2025
1.0.0 143 5/8/2025