Serilog.Sinks.Map
2.0.0-dev-00048
Prefix Reserved
See the version list below for details.
dotnet add package Serilog.Sinks.Map --version 2.0.0-dev-00048
NuGet\Install-Package Serilog.Sinks.Map -Version 2.0.0-dev-00048
<PackageReference Include="Serilog.Sinks.Map" Version="2.0.0-dev-00048" />
paket add Serilog.Sinks.Map --version 2.0.0-dev-00048
#r "nuget: Serilog.Sinks.Map, 2.0.0-dev-00048"
// Install Serilog.Sinks.Map as a Cake Addin #addin nuget:?package=Serilog.Sinks.Map&version=2.0.0-dev-00048&prerelease // Install Serilog.Sinks.Map as a Cake Tool #tool nuget:?package=Serilog.Sinks.Map&version=2.0.0-dev-00048&prerelease
Serilog.Sinks.Map
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 | Versions 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. |
NuGet packages (27)
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 |
|
YYApp.Serilog
YYApp Serilog common and defaults |
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 | 158,179 | 7/11/2024 |
2.0.0-dev-00048 | 95 | 7/10/2024 |
1.0.2 | 8,818,771 | 12/1/2020 |
1.0.2-dev-00040 | 371 | 12/1/2020 |
1.0.2-dev-00031 | 1,115 | 4/17/2020 |
1.0.1 | 324,000 | 2/19/2020 |
1.0.1-dev-00028 | 475 | 2/13/2020 |
1.0.1-dev-00025 | 4,678 | 5/2/2019 |
1.0.0 | 1,132,947 | 4/21/2019 |
1.0.0-dev-00020 | 643 | 4/21/2019 |
1.0.0-dev-00017 | 22,365 | 9/23/2018 |
1.0.0-dev-00012 | 4,627 | 10/28/2017 |
1.0.0-dev-00008 | 870 | 10/26/2017 |
1.0.0-dev-00006 | 834 | 10/26/2017 |
1.0.0-dev-00004 | 865 | 10/24/2017 |
1.0.0-dev-00001 | 1,048 | 6/6/2017 |