LoggingInstaller — Web
Key: Logging
Default Enabled: ✅
Package: SaveApis.Framework.Web
Purpose
Replaces all default .NET logging providers with Serilog and configures a formatted ANSI console sink. This ensures structured, readable log output with consistent formatting across all environments.
What It Does
- Calls
builder.Logging.ClearProviders()to remove default providers - Registers Serilog via
builder.Services.AddSerilog() - Enriches log context automatically
- Writes to the console with the pattern:
[HH:mm:ss LVL] (SourceContext) Message - Applies built-in minimum-level overrides for noisy framework namespaces:
Microsoft.AspNetCore→WarningSystem.Net.Http→Warning
- Supports custom per-source overrides via configuration
Dependencies
No dependencies on other installers. Runs first in the default execution order.
Configuration
appsettings.json
{
"Logging": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Warning",
"MyNamespace.MyService": "Debug"
}
}
}
Environment Variables
| Variable | Type | Default | Description |
|---|---|---|---|
Logging__Default |
LogEventLevel |
Information |
Global minimum log level |
Logging__Override__<source> |
LogEventLevel |
– | Override for a specific source namespace |
LogEventLevel values: Verbose, Debug, Information, Warning, Error, Fatal
Example:
Logging__Default=Debug
Logging__Override__Microsoft.AspNetCore=Warning
Logging__Override__MyNamespace=Information
InstallerContext Extension
installer.WithLogging(bool enabled = true);
Example — disable in tests:
installer.WithLogging(false);
Related
- Web Framework Overview
- OpenTelemetryInstaller — exports logs via OTLP in addition to console output