Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/serilog/serilog-enrichers-environment
Enrich Serilog log events with properties from System.Environment.
https://github.com/serilog/serilog-enrichers-environment
Last synced: 1 day ago
JSON representation
Enrich Serilog log events with properties from System.Environment.
- Host: GitHub
- URL: https://github.com/serilog/serilog-enrichers-environment
- Owner: serilog
- License: apache-2.0
- Created: 2016-03-09T06:12:24.000Z (over 8 years ago)
- Default Branch: dev
- Last Pushed: 2024-06-20T06:43:23.000Z (5 months ago)
- Last Synced: 2024-11-07T17:42:39.197Z (8 days ago)
- Language: C#
- Size: 112 KB
- Stars: 80
- Watchers: 17
- Forks: 33
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Serilog.Enrichers.Environment
Enriches Serilog events with information from the execution environment.
[![Build status](https://ci.appveyor.com/api/projects/status/yfbvbdxd5vwh6955?svg=true)](https://ci.appveyor.com/project/serilog/serilog-enrichers-environment) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Enrichers.Environment.svg?style=flat)](https://www.nuget.org/packages/Serilog.Enrichers.Environment/)To use the enricher, first install the NuGet package:
```powershell
dotnet add package Serilog.Enrichers.Environment
```Then, apply the enricher to you `LoggerConfiguration`:
```csharp
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 environmentVariableName, string propertyName = null)` - adds an `environmentVariableName` property to the log event with the value for the specified environment variable. Optional `propertyName` will override `environmentVariableName` as the name of the attached property.Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).