Soenneker.Utils.Logger 4.0.538

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.Logger --version 4.0.538
                    
NuGet\Install-Package Soenneker.Utils.Logger -Version 4.0.538
                    
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="4.0.538" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.Logger" Version="4.0.538" />
                    
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 4.0.538
                    
#r "nuget: Soenneker.Utils.Logger, 4.0.538"
                    
#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@4.0.538
                    
#: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=4.0.538
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.Logger&version=4.0.538
                    
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

A useful utility library dealing with Serilog logging.

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 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. 
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
4.0.541 0 8/31/2026
4.0.540 0 8/31/2026
4.0.539 0 8/31/2026
4.0.538 0 8/30/2026
4.0.537 20 8/30/2026
4.0.536 1,288 8/30/2026
4.0.535 531 8/30/2026
4.0.534 1,396 8/30/2026
4.0.533 41 8/29/2026
4.0.532 745 8/29/2026
4.0.531 1,960 8/29/2026
4.0.530 35,709 8/26/2026
4.0.529 833 8/26/2026
4.0.528 663 8/25/2026
4.0.527 10,927 8/22/2026
4.0.526 19,820 8/18/2026
4.0.525 13,228 8/13/2026
4.0.524 1,998 8/12/2026
4.0.523 42,323 8/8/2026
4.0.522 16,863 8/7/2026
Loading failed

Correct shared Serilog switch initialization