Skip to content

Commit 2aa420a

Browse files
authored
Merge pull request #7 from serilog/dev
2.1 Release
2 parents 796239d + 97542a0 commit 2aa420a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

Diff for: CHANGES.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1-
2.0.0
2-
- Moved to new project
3-
- DotNet Core support
1+
2.1.0
2+
3+
* #4 - use `$HOSTNAME` to derive machine name on OSX/Linux
4+
5+
2.0.0
6+
7+
* Moved to new project
8+
* DotNet Core support

Diff for: src/Serilog.Enrichers.Environment/Enrichers/MachineNameEnricher.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
4242
#if ENV_USER_NAME
4343
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.MachineName);
4444
#else
45-
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, Environment.GetEnvironmentVariable("COMPUTERNAME"));
45+
var machineName = Environment.GetEnvironmentVariable("COMPUTERNAME");
46+
if (string.IsNullOrWhiteSpace(machineName))
47+
machineName = Environment.GetEnvironmentVariable("HOSTNAME");
48+
49+
_cachedProperty = _cachedProperty ?? propertyFactory.CreateProperty(MachineNamePropertyName, machineName);
4650
#endif
4751
logEvent.AddPropertyIfAbsent(_cachedProperty);
4852
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.1-*",
2+
"version": "2.1.0-*",
33
"description": "Enrich Serilog log events with properties from System.Environment.",
44
"authors": [
55
"Serilog Contributors"

0 commit comments

Comments
 (0)