Soenneker.Utils.Logger
4.0.565
Prefix Reserved
dotnet add package Soenneker.Utils.Logger --version 4.0.565
NuGet\Install-Package Soenneker.Utils.Logger -Version 4.0.565
<PackageReference Include="Soenneker.Utils.Logger" Version="4.0.565" />
<PackageVersion Include="Soenneker.Utils.Logger" Version="4.0.565" />
<PackageReference Include="Soenneker.Utils.Logger" />
paket add Soenneker.Utils.Logger --version 4.0.565
#r "nuget: Soenneker.Utils.Logger, 4.0.565"
#:package Soenneker.Utils.Logger@4.0.565
#addin nuget:?package=Soenneker.Utils.Logger&version=4.0.565
#tool nuget:?package=Soenneker.Utils.Logger&version=4.0.565
Soenneker.Utils.Logger
Builds cached Microsoft ILogger<T> instances backed by Serilog's global logger and exposes a shared runtime level switch.
Installation
dotnet add package Soenneker.Utils.Logger
Quick start
using Soenneker.Utils.Logger;
Call the static LoggerUtil methods directly; no dependency-injection registration is required.
Configure Serilog before creating loggers
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Core;
using Soenneker.Utils.Logger;
LoggingLevelSwitch levelSwitch = LoggerUtil.GetSwitch();
Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.WriteTo.Console()
.CreateLogger();
ILogger<Worker> logger = LoggerUtil.BuildLogger<Worker>();
The console call requires the corresponding Serilog sink package. Configure Log.Logger before
the first call to BuildLogger or Init: the utility's factory captures that logger and does not
own or dispose it. Application shutdown remains responsible for flushing and closing Serilog.
Change the level at runtime
LoggerUtil.SetLogLevel(LogEventLevel.Warning);
// Or resolve the configured level through Soenneker's configuration logging extension:
LoggerUtil.SetLogLevelFromConfig(configuration);
Level changes affect a logger only when its Serilog configuration uses the shared switch returned
by GetSwitch, as in the setup above. The switch begins at Verbose; sinks and additional Serilog
overrides can still filter events more restrictively.
BuildLogger<T> creates a Microsoft ILogger<T> with category T through the cached factory.
Init is optional because BuildLogger initializes the factory on first use.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Serilog.Extensions.Logging (>= 10.0.0)
- Soenneker.Atomics.ValueBools (>= 4.0.44)
- Soenneker.Extensions.Configuration.Logging (>= 4.0.234)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Utils.Logger:
| Package | Downloads |
|---|---|
|
Soenneker.Tests.Unit
A base test providing faker and autofaker capabilities |
|
|
Soenneker.Extensions.LoggerConfiguration
A set of useful Serilog LoggerConfiguration extension methods |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.565 | 414 | 9/16/2026 |
| 4.0.564 | 2,057 | 9/16/2026 |
| 4.0.563 | 3,202 | 9/15/2026 |
| 4.0.562 | 69 | 9/15/2026 |
| 4.0.561 | 24,505 | 9/13/2026 |
| 4.0.560 | 3,156 | 9/13/2026 |
| 4.0.559 | 762 | 9/13/2026 |
| 4.0.558 | 5,572 | 9/12/2026 |
| 4.0.552 | 23,982 | 9/9/2026 |
| 4.0.551 | 3,208 | 9/9/2026 |
| 4.0.550 | 5,481 | 9/8/2026 |
| 4.0.549 | 9,087 | 9/8/2026 |
| 4.0.548 | 3,909 | 9/8/2026 |
| 4.0.547 | 10,181 | 9/7/2026 |
| 4.0.546 | 97 | 9/7/2026 |
| 4.0.545 | 15,866 | 9/5/2026 |
| 4.0.544 | 13,212 | 9/4/2026 |
| 4.0.543 | 42,753 | 9/1/2026 |
| 4.0.542 | 1,924 | 8/31/2026 |
| 4.0.541 | 6,722 | 8/31/2026 |
Update dependency Soenneker.Extensions.Configuration.Logging to 4.0.233 (#667)