Skip to content

Commit c4544d0

Browse files
authored
Merge pull request #10 from serilog/dev
2.1.1 Release (WIP)
2 parents 2aa420a + ee2aca0 commit c4544d0

File tree

5 files changed

+49
-13
lines changed

5 files changed

+49
-13
lines changed

Diff for: README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
# Serilog.Enrichers.Environment
22

3-
The environment enricher for Serilog.
3+
Enriches Serilog events with information from the process environment.
44

55
[![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/)
66

7-
87
To use the enricher, first install the NuGet package:
98

109
```powershell
1110
Install-Package Serilog.Enrichers.Environment
1211
```
1312

14-
* [Documentation](https://github.com/serilog/serilog/wiki)
13+
Then, apply the enricher to you `LoggerConfiguration`:
14+
15+
```csharp
16+
Log.Logger = new LoggerConfiguration()
17+
.Enrich.WithMachineName()
18+
// ...other configuration...
19+
.CreateLogger();
20+
```
21+
22+
The `WithMachineName()` enricher will add a `MachineName` property to produced events.
23+
24+
### Included enrichers
25+
26+
The package includes:
27+
28+
* `WithMachineName()` - adds `MachineName` based on either `%COMPUTERNAME%` (Windows) or `$HOSTNAME` (macOS, Linux)
29+
* `WithEnvironmentUserName()` - adds `EnvironmentUserName` based on `USERNAME` and `USERDOMAIN` (if available)
1530

1631
Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).

Diff for: src/Serilog.Enrichers.Environment/project.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.1.0-*",
2+
"version": "2.1.1-*",
33
"description": "Enrich Serilog log events with properties from System.Environment.",
44
"authors": [
55
"Serilog Contributors"
@@ -25,10 +25,10 @@
2525
"net4.5": {
2626
"define": ["ENV_USER_NAME"]
2727
},
28-
"netstandard1.5": {
28+
"netstandard1.3": {
2929
"dependencies": {
3030
"System.Runtime.Extensions": "4.1.0"
3131
}
3232
}
3333
}
34-
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Serilog.Events;
2+
using Serilog.Tests.Support;
3+
using Xunit;
4+
5+
namespace Serilog.Tests.Enrichers
6+
{
7+
public class EnvironmentMachineNameEnricherTests
8+
{
9+
[Fact]
10+
public void EnvironmentMachineNameEnricherIsApplied()
11+
{
12+
LogEvent evt = null;
13+
var log = new LoggerConfiguration()
14+
.Enrich.WithMachineName()
15+
.WriteTo.Sink(new DelegatingSink(e => evt = e))
16+
.CreateLogger();
17+
18+
log.Information(@"Has an MachineName property");
19+
20+
Assert.NotNull(evt);
21+
Assert.NotEmpty((string)evt.Properties["MachineName"].LiteralValue());
22+
}
23+
}
24+
}

Diff for: test/Serilog.Enrichers.Environment.Tests/Enrichers/EnvironmentUserNameEnricherTests.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#if PROCESS
2-
3-
using Serilog.Events;
1+
using Serilog.Events;
42
using Serilog.Tests.Support;
53
using Xunit;
64

@@ -24,4 +22,3 @@ public void EnvironmentUserNameEnricherIsApplied()
2422
}
2523
}
2624
}
27-
#endif

Diff for: test/Serilog.Enrichers.Environment.Tests/project.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
{
1+
{
22
"testRunner": "xunit",
3-
"dependencies": {
3+
"dependencies": {
44
"xunit": "2.1.0",
5-
"dotnet-test-xunit": "1.0.0-rc2-build10015",
5+
"dotnet-test-xunit": "1.0.0-*",
66
"Serilog.Enrichers.Environment": {
77
"target": "project"
88
}

0 commit comments

Comments
 (0)