IronAlpine.Logging.Serilog 2.0.0

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

IronAlpine.Logging.Serilog

IronAlpine.Logging.Serilog provides Serilog host integration and mediator pipeline logging for IronAlpine services.

It covers:

  • host bootstrap logging
  • service registration for logging options
  • mediator request/response logging behavior
  • event metadata enrichment
  • sensitive-data masking
  • duplicate sink avoidance for common sink configurations

Why

Use this package when a service wants structured logs without rebuilding logging bootstrap, metadata enrichment, and masking policies.

Install

dotnet add package IronAlpine.Logging.Serilog

Quick Start

builder.Host.UseIronAlpineSerilog("personnel-service");

Public Surface

  • UseIronAlpineSerilog(...)
  • AddIronAlpineSerilog(...)
  • LoggingBehavior<TRequest, TResponse>

Configuration

Configuration root:

{
  "IronAlpine": {
    "Logging": {
      "Serilog": {
        "LogRequestPayloads": true,
        "LogResponsePayloads": false,
        "MaskValue": "***",
        "SensitivePropertyNames": [
          "password",
          "token",
          "secret",
          "authorization"
        ]
      }
    }
  },
  "Serilog": {
    "WriteTo": [
      {
        "Name": "Console"
      }
    ]
  }
}

Options Deep Dive

LogRequestPayloads

  • controls whether mediator requests are serialized into logs
  • useful for diagnostics, but may be noisy or risky for large payloads

LogResponsePayloads

  • same tradeoff as request payload logging
  • keep disabled by default unless you need deep response diagnostics

MaskValue

  • default replacement for masked values
  • should be stable and obvious in logs

SensitivePropertyNames

  • list of property names masked during destructuring
  • best practice: include auth, secret, and token-bearing names

Host Integration

UseIronAlpineSerilog(...):

  • binds Serilog configuration
  • wires IronAlpine-specific enrichers and masking
  • avoids double-adding common sinks such as Seq or OpenTelemetry when they already exist in configuration

Use explicit service name when assembly name is not stable enough for operations.

Mediator Behavior

LoggingBehavior<TRequest, TResponse> is intended to sit near the outer edge of the pipeline.

Recommended order:

  1. logging
  2. caching
  3. validation
  4. transaction / unit of work

That keeps diagnostic context visible even when validation or caching short-circuits execution.

Metadata Enrichment

When IEventMetadataProvider is available, logs receive:

  • trace id
  • correlation id
  • causation id
  • tenant id

This makes log-to-trace and log-to-message pivots much easier in operations.

Masking

The built-in masking policy redacts common sensitive fields such as:

  • password
  • token
  • secret
  • authorization
  • apiKey
  • refreshToken

Extend the list through options when your domain has additional sensitive names.

Combinations

Logging + Web.AspNetCore

Recommended for all HTTP services so request metadata appears in logs automatically.

Logging + OpenTelemetry

Recommended when operators correlate logs and traces in the same incident workflow.

Logging + Data.EFCore.Mediator

Recommended when request-level logs must be aligned with transaction boundaries and command intent auditing.

Troubleshooting

Logs appear twice

Cause:

  • same sink configured both in Serilog:WriteTo and added manually elsewhere

Fix:

  • prefer centralized configuration and let IronAlpine dedupe common sinks

Sensitive fields leak into logs

Cause:

  • property name not included in masking list
  • payload logging too broad for the domain

Fix:

  • extend SensitivePropertyNames
  • disable payload logging for risky request types

Correlation values are missing

Cause:

  • metadata provider not registered
  • web middleware or messaging runtime missing

Fix:

  • verify IronAlpine.Web.AspNetCore or equivalent metadata-producing runtime is registered
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 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.0.0 1,490 4/2/2026
Loading failed

Stable mediator release with request/response, notification publish strategies, streaming, and dependency injection integration.