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
<PackageReference Include="IronAlpine.Logging.Serilog" Version="2.0.0" />
<PackageVersion Include="IronAlpine.Logging.Serilog" Version="2.0.0" />
<PackageReference Include="IronAlpine.Logging.Serilog" />
paket add IronAlpine.Logging.Serilog --version 2.0.0
#r "nuget: IronAlpine.Logging.Serilog, 2.0.0"
#:package IronAlpine.Logging.Serilog@2.0.0
#addin nuget:?package=IronAlpine.Logging.Serilog&version=2.0.0
#tool nuget:?package=IronAlpine.Logging.Serilog&version=2.0.0
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:
- logging
- caching
- validation
- 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:
passwordtokensecretauthorizationapiKeyrefreshToken
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:WriteToand 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.AspNetCoreor equivalent metadata-producing runtime is registered
| Product | Versions 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. |
-
net10.0
- IronAlpine.Framework.Abstractions (>= 2.0.0)
- IronAlpine.Kernel (>= 2.0.0)
- IronAlpine.Mediator.Abstractions (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.7)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Span (>= 3.1.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
- Serilog.Sinks.Seq (>= 9.0.0)
-
net9.0
- IronAlpine.Framework.Abstractions (>= 2.0.0)
- IronAlpine.Kernel (>= 2.0.0)
- IronAlpine.Mediator.Abstractions (>= 2.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.7)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Span (>= 3.1.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
- Serilog.Sinks.Seq (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Stable mediator release with request/response, notification publish strategies, streaming, and dependency injection integration.