SaveApis.Framework

Documentation for SaveApis.Framework

View on GitHub

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


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.AspNetCoreWarning ❌ (no ASP.NET Core)
System.Net.HttpWarning
Microsoft.Extensions.HttpWarning