Enriches Serilog events with information from the process environment.
To use the enricher, first install the NuGet package:
Install-Package Serilog.Enrichers.EnvironmentThen, 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.
The package includes:
WithMachineName()- addsMachineNamebased on either%COMPUTERNAME%(Windows) or$HOSTNAME(macOS, Linux)WithEnvironmentUserName()- addsEnvironmentUserNamebased onUSERNAMEandUSERDOMAIN(if available)WithEnvironmentName()- addsEnvironmentNamebased onASPNETCORE_ENVIRONMENTorDOTNET_ENVIRONMENT(when both are available then 'ASPNETCORE_ENVIRONMENT' takes precedence, when none are available then the fallback value will be 'Production')
Copyright © 2016 Serilog Contributors - Provided under the Apache License, Version 2.0.