LoggingInstaller — Console
Key: Logging
Default Enabled: ✅
Package: SaveApis.Framework.Console
Purpose
Replaces all default .NET logging providers with Serilog and configures a formatted ANSI console sink for background worker and hosted service applications.
What It Does
- Calls
builder.Logging.ClearProviders() - 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:
System.Net.Http→WarningMicrosoft.Extensions.Http→Warning
Dependencies
No dependencies on other installers.
Configuration
appsettings.json
{
"Logging": {
"Default": "Information",
"Override": {
"System.Net.Http": "Warning",
"MyNamespace.MyWorker": "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=Information
Logging__Override__MyNamespace__MyWorker=Debug
Logging__Override__System__Net__Http=Warning
Note: Double underscores (
__) are used as the hierarchy separator in environment variables. Dots in namespace names should be replaced with double underscores when used as environment variable keys, however .NET’s configuration system also accepts the exact dotted form — check your deployment environment.
InstallerContext Extension
installer.WithLogging(bool enabled = true);
Difference from Web LoggingInstaller
The Console LoggingInstaller is functionally equivalent to the Web version, with one difference in the built-in overrides:
| Override | Web | Console |
|---|---|---|
Microsoft.AspNetCore → Warning |
✅ | ❌ (no ASP.NET Core) |
System.Net.Http → Warning |
✅ | ✅ |
Microsoft.Extensions.Http → Warning |
❌ | ✅ |
Related
- Console Framework Overview
- OpenTelemetryInstaller — exports logs via OTLP in addition to console output