Serilog.Enrichers.Context 3.0.0-develop-00024

Enrich Serilog event with environment variables.

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.
Install-Package Serilog.Enrichers.Context -Version 3.0.0-develop-00024
dotnet add package Serilog.Enrichers.Context --version 3.0.0-develop-00024
paket add Serilog.Enrichers.Context --version 3.0.0-develop-00024
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

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&lt;string, object&gt;)

.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

Version History

Version Downloads Last updated
4.0.0 1 7/21/2018
3.0.0-develop-00024 (current) 638 4/21/2018
2.4.0 34,733 1/14/2018
2.3.0 23,025 4/5/2017
2.2.37 1,816 11/26/2016
2.0.5 2,376 9/30/2016
1.1.3 183 9/22/2016