Serilog.Enrichers.Context 3.0.0-develop-00024

.NET Core 2.0 .NET Standard 1.3 .NET Framework 4.5.2
This is a prerelease version of Serilog.Enrichers.Context.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Serilog.Enrichers.Context --version 3.0.0-develop-00024
NuGet\Install-Package Serilog.Enrichers.Context -Version 3.0.0-develop-00024
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.Enrichers.Context" Version="3.0.0-develop-00024" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Enrichers.Context --version 3.0.0-develop-00024
#r "nuget: Serilog.Enrichers.Context, 3.0.0-develop-00024"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Enrichers.Context as a Cake Addin
#addin nuget:?package=Serilog.Enrichers.Context&version=3.0.0-develop-00024&prerelease

// Install Serilog.Enrichers.Context as a Cake Tool
#tool nuget:?package=Serilog.Enrichers.Context&version=3.0.0-develop-00024&prerelease

Serilog.Enrichers.Context

Enriches Serilog events with information from the environment variables or user provided custom property.

Getting started

Install Serilog.Enrichers.Context from NuGet

Install-Package Serilog.Enrichers.Context

Enriching with environment variables.

Configure logger by calling .Enrich.WithEnvironment(...)

####Example

var logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .Enrich.WithEnvironment("OS")
    .CreateLogger();
    
logger.Information("This informational message will enrich with OS name");

When a compatible sink is used, in this case Serilog.Sinks.AzureDocumentDB, following log message will be emitted to DocumentDb:

  {
    "Timestamp": "2016-09-22T07:16:34.0314959-04:00",
    "Level": "Information",
    "MessageTemplate": "This informational message will enrich with OS name",
    "Properties": {
      "OS": "Windows_NT"
    },
    "id": "580bce0b-76d4-f510-60f4-70da00636bc3"
  }

Enriching with user defined property.

Configure logger by calling .Enrich.WithProperty(KeyValuePair<string, object>)

.Enrich.WithProperty(...) is very useful when multiple applications are logging to centralized store and you want to distinguish logs by some unique property for better discoverability.

####Example

var logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .Enrich.WithProperty(new KeyValuePair<string, object>("applicationId", "demo"));
    .CreateLogger();
    
logger.Information("This informational message will enrich with custom property");    

Assuming AzureDocumentDB sink is configured, one should see following log message in Azure DocumentDb collection.

  {
    "Timestamp": "2016-09-22T07:33:52.9807951-04:00",
    "Level": "Information",
    "MessageTemplate": "This informational message will enrich with custom property",
    "Properties": {
      "applicationId": "demo"
    },
    "id": "9b672004-4e6b-31a2-3e92-5ea49361c312"
  }

Build status

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (20)

Showing the top 5 NuGet packages that depend on Serilog.Enrichers.Context:

Package Downloads
MyJetWallet.Sdk.Service

Package Description

DocWorks.Common

This is common code in DocWorks CMS Application

M5x.Serilog

Macula SeriLog Abstraction

Swisschain.Sdk.Server

Package Description

Zavi.Extensions.Logging

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Serilog.Enrichers.Context:

Repository Stars
ChaosRecipeEnhancer/EnhancePoEApp
Streamline your Chaos Recipe gains!
Version Downloads Last updated
4.6.0 166,307 7/1/2022
4.5.0-develop-00040 52,527 3/11/2019
4.2.0 3,362,214 1/2/2019
4.0.0 125,659 7/21/2018
3.0.0-develop-00024 1,841 4/21/2018
2.4.0 365,876 1/14/2018
2.3.0 50,426 4/5/2017
2.2.37 6,758 11/26/2016
2.0.5 3,628 9/30/2016
1.1.3 1,252 9/22/2016