Serilog.Sinks.Map 2.0.0

Prefix Reserved
dotnet add package Serilog.Sinks.Map --version 2.0.0                
NuGet\Install-Package Serilog.Sinks.Map -Version 2.0.0                
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="Serilog.Sinks.Map" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.Map --version 2.0.0                
#r "nuget: Serilog.Sinks.Map, 2.0.0"                
#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.
// Install Serilog.Sinks.Map as a Cake Addin
#addin nuget:?package=Serilog.Sinks.Map&version=2.0.0

// Install Serilog.Sinks.Map as a Cake Tool
#tool nuget:?package=Serilog.Sinks.Map&version=2.0.0                

Serilog.Sinks.Map Build status NuGet Pre Release

A Serilog sink wrapper that dispatches events based on a property value.

Getting started

Install the package from NuGet:

dotnet add package Serilog.Sinks.Map

The WriteTo.Map() method accepts a property name to use as a sink selector, a default value to use when the property is not attached, and a function that configures the sinks based on each property value.

For example, when using Serilog.Sinks.File:

dotnet add package Serilog.Sinks.File

The value of a log event property like Name can be inserted into log filenames:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Map("Name", "Other", (name, wt) => wt.File($"./logs/log-{name}.txt"))
    .CreateLogger();

Log.Information("Hello, {Name}!", "Alice");
// -> Event written to log-Alice.txt

Log.Information("Hello, {Name}!", "Bob");
// -> Event written to log-Bob.txt

Log.Information("Shutting down");
// -> Event written to log-Other.txt

Log.CloseAndFlush();

Limiting the number of open sinks

By default, the target sinks opened by this sink won't be closed/disposed until the mapped sink is. This is efficient for dispatching to a finite number of sinks, e.g. file-per-log-level and so-on, but isn't suitable when the set of possible key values is open-ended.

To limit the number of target sinks that will be kept open in the map, specify sinkMapCountLimit:

    .WriteTo.Map("Name",
                 "Other",
                 (name, wt) => wt.File($"./logs/log-{name}.txt"),
                 sinkMapCountLimit: 10)

To keep no sinks open, i.e. close them immediately after processing each event, a sinkMapCountLimit of zero may be specified.

Configuration with <appSettings> and appSettings.json

Serilog.Sinks.Map is built around a mapping function, and as such, isn't able to be configured using XML or JSON configuration.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (28)

Showing the top 5 NuGet packages that depend on Serilog.Sinks.Map:

Package Downloads
Umbraco.Cms.Infrastructure

Contains the infrastructure assembly needed to run Umbraco CMS.

UmbracoCms.Core

Contains the core assemblies needed to run Umbraco Cms. This package only contains assemblies and can be used for package development. Use the UmbracoCms package to setup Umbraco in Visual Studio as an ASP.NET project.

HwApp.Serilog

HwApp Serilog common and defaults

Sukt.SeriLog

Package Description

Microsoft.ComponentDetection

Package Description

GitHub repositories (12)

Showing the top 5 popular GitHub repositories that depend on Serilog.Sinks.Map:

Repository Stars
umbraco/Umbraco-CMS
Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
GitTools/GitVersion
From git log to SemVer in no time
microsoft/sbom-tool
The SBOM tool is a highly scalable and enterprise ready tool to create SPDX 2.2 compatible SBOMs for any variety of artifacts.
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 7
dotnet/dotnet
Home of .NET's Virtual Monolithic Repository which includes all the code needed to build the .NET SDK from source
Version Downloads Last updated
2.0.0 219,579 7/11/2024
2.0.0-dev-00048 98 7/10/2024
1.0.2 9,001,164 12/1/2020
1.0.2-dev-00040 372 12/1/2020
1.0.2-dev-00031 1,117 4/17/2020
1.0.1 325,080 2/19/2020
1.0.1-dev-00028 477 2/13/2020
1.0.1-dev-00025 4,682 5/2/2019
1.0.0 1,137,760 4/21/2019
1.0.0-dev-00020 645 4/21/2019
1.0.0-dev-00017 22,926 9/23/2018
1.0.0-dev-00012 4,639 10/28/2017
1.0.0-dev-00008 871 10/26/2017
1.0.0-dev-00006 835 10/26/2017
1.0.0-dev-00004 867 10/24/2017
1.0.0-dev-00001 1,050 6/6/2017