Skip to main content
.NETFramework4.6.2.NETFramework4.7.1net6.0net8.0.NETStandard2.0

Enrich Serilog log events with properties from System.Environment.

Published
Jun 9, 2024
2y ago
Total Downloads
311.4M
311,374,524

Install

dotnet add package Serilog.Enrichers.Environment --version 3.0.0-dev-00811
ProductVersions
.NET
net6.0net8.0
.NET Standard
netstandard2.0
Other
.NETFramework4.6.2.NETFramework4.7.1

README

Serilog.Enrichers.Environment

Enriches Serilog events with information from the execution environment.

Build status NuGet Version

To use the enricher, first install the NuGet package:

dotnet add package Serilog.Enrichers.Environment

Then, apply the enricher to you LoggerConfiguration:

Log.Logger = new LoggerConfiguration()
    .Enrich.WithMachineName()
    // ...other configuration...
    .CreateLogger();

The WithMachineName() enricher will add a MachineName property to produced events.

Included enrichers

The package includes:

  • WithMachineName() - adds MachineName based on either %COMPUTERNAME% (Windows) or $HOSTNAME (macOS, Linux)
  • WithEnvironmentUserName() - adds EnvironmentUserName based on USERNAME and USERDOMAIN (if available)
  • WithEnvironmentName() - adds EnvironmentName based on ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT (when both are available then 'ASPNETCORE_ENVIRONMENT' takes precedence, when none are available then the fallback value will be 'Production')
  • WithEnvironmentVariable(string envVarName, string propertyName = null) - adds an <envVarName> property to the log event with the value for the specified environment variable. Optional <propertyName> will override <envVarName> as propertyName.

Copyright © 2016 Serilog Contributors - Provided under the Apache License, Version 2.0.

Changes from Previous Version

v3.0.0-dev-00806v3.0.0-dev-00811
Added Frameworks
.NETFramework4.6.2.NETFramework4.7.1net6.0net8.0
Removed Frameworks
.NETFramework4.5.NETStandard1.3.NETStandard1.5
Added Dependencies
Serilog(.NETFramework4.6.2)
Serilog(.NETFramework4.7.1)
Serilog(net6.0)
Serilog(net8.0)
Removed Dependencies
Serilog(.NETFramework4.5)
NETStandard.Library(.NETStandard1.3)
Serilog(.NETStandard1.3)
System.Net.NameResolution(.NETStandard1.3)
NETStandard.Library(.NETStandard1.5)
Serilog(.NETStandard1.5)

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 5 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.