Soenneker.Utils.Logger 11.0.601

Prefix Reserved
dotnet add package Soenneker.Utils.Logger --version 11.0.601
                    
NuGet\Install-Package Soenneker.Utils.Logger -Version 11.0.601
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Utils.Logger" Version="11.0.601" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Logger" Version="11.0.601" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.Logger" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Utils.Logger --version 11.0.601
                    
#r "nuget: Soenneker.Utils.Logger, 11.0.601"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Utils.Logger@11.0.601
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Utils.Logger&version=11.0.601
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Logger&version=11.0.601
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.601 0 11/29/2026
11.0.600 14,948 11/18/2026
11.0.599 4,442 11/18/2026
11.0.598 256 11/18/2026
11.0.597 6,708 11/18/2026
11.0.596 30,872 11/11/2026
11.0.595 1,347 11/11/2026
11.0.594 102 11/11/2026
11.0.593 4,110 11/10/2026
11.0.592 113 11/10/2026
11.0.591 82,689 10/26/2026
11.0.590 303 10/26/2026
11.0.589 316 10/26/2026
4.0.588 41,838 10/15/2026
4.0.587 171 10/14/2026
4.0.586 2,110 10/14/2026
4.0.585 9,160 10/14/2026
4.0.584 928 10/14/2026
4.0.578 3,488 10/13/2026
4.0.577 6,081 10/13/2026
Loading failed

Update dependency Soenneker.Extensions.Configuration.Logging to 11.0.266 (#708)