diff --git a/.idea/.idea.serilog-enrichers-environment/.idea/.gitignore b/.idea/.idea.serilog-enrichers-environment/.idea/.gitignore
new file mode 100644
index 0000000..65b0d27
--- /dev/null
+++ b/.idea/.idea.serilog-enrichers-environment/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/projectSettingsUpdater.xml
+/modules.xml
+/.idea.serilog-enrichers-environment.iml
+/contentModel.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.serilog-enrichers-environment/.idea/encodings.xml b/.idea/.idea.serilog-enrichers-environment/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.serilog-enrichers-environment/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.serilog-enrichers-environment/.idea/indexLayout.xml b/.idea/.idea.serilog-enrichers-environment/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.serilog-enrichers-environment/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.serilog-enrichers-environment/.idea/vcs.xml b/.idea/.idea.serilog-enrichers-environment/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/.idea.serilog-enrichers-environment/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Build.ps1 b/Build.ps1
index fab3228..7886e8f 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -3,8 +3,8 @@ echo "build: Build started"
Push-Location $PSScriptRoot
if(Test-Path .\artifacts) {
- echo "build: Cleaning ./artifacts"
- Remove-Item ./artifacts -Force -Recurse
+ echo "build: Cleaning .\artifacts"
+ Remove-Item .\artifacts -Force -Recurse
}
& dotnet restore --no-cache
@@ -16,45 +16,33 @@ $commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
echo "build: Package version suffix is $suffix"
-echo "build: Build version suffix is $buildSuffix"
+echo "build: Build version suffix is $buildSuffix"
-foreach ($src in gci src/*) {
+foreach ($src in ls src/*) {
Push-Location $src
echo "build: Packaging project in $src"
- & dotnet build -c Release --version-suffix=$buildSuffix
-
- if($suffix) {
- & dotnet pack -c Release --include-source --no-build -o ../../artifacts --version-suffix=$suffix
+ & dotnet build -c Release --version-suffix=$buildSuffix -p:ContinuousIntegrationBuild=true
+ if ($suffix) {
+ & dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
- & dotnet pack -c Release --include-source --no-build -o ../../artifacts
+ & dotnet pack -c Release -o ..\..\artifacts --no-build
}
- if($LASTEXITCODE -ne 0) { exit 1 }
+ if($LASTEXITCODE -ne 0) { throw "build failed" }
Pop-Location
}
-foreach ($test in gci test/*.Tests) {
+foreach ($test in ls test/*.Tests) {
Push-Location $test
echo "build: Testing project in $test"
& dotnet test -c Release
- if($LASTEXITCODE -ne 0) { exit 3 }
-
- Pop-Location
-}
-
-foreach ($test in ls test/*.PerformanceTests) {
- Push-Location $test
-
- echo "build: Building performance test project in $test"
-
- & dotnet build -c Release
- if($LASTEXITCODE -ne 0) { exit 2 }
+ if($LASTEXITCODE -ne 0) { throw "tests failed" }
Pop-Location
}
-Pop-Location
+Pop-Location
\ No newline at end of file
diff --git a/README.md b/README.md
index 15923d1..7675749 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,13 @@
# Serilog.Enrichers.Environment
-Enriches Serilog events with information from the process 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
-Install-Package Serilog.Enrichers.Environment
+dotnet add package Serilog.Enrichers.Environment
```
Then, apply the enricher to you `LoggerConfiguration`:
@@ -28,6 +28,6 @@ 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 `` property to the log event with the value for the specified enviroment variable. Optional `` will override `` as propertyName.
+ * `WithEnvironmentVariable(string envVarName, string propertyName = null)` - adds an `` property to the log event with the value for the specified environment variable. Optional `` will override `` as propertyName.
Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
diff --git a/appveyor.yml b/appveyor.yml
index 8029461..d367cf6 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,26 +1,26 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2022
-configuration: Release
-install:
- - ps: mkdir -Force ".\build\" | Out-Null
-
build_script:
-- ps: ./Build.ps1
+ - pwsh: ./Build.ps1
test: off
artifacts:
-- path: artifacts/Serilog.*.nupkg
+ - path: artifacts/Serilog.*.nupkg
+ - path: artifacts/Serilog.*.snupkg
deploy:
-- provider: NuGet
- api_key:
- secure: dw2kT1B1gpFLOE7ZHhExKgcspS+tf5maUq0jEdH17YyHjUxQpemGcwvbe4nuf/Ic
- skip_symbols: true
- on:
- branch: /^(main|dev)$/
-- provider: GitHub
- auth_token:
- secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
- artifact: /Serilog.*\.nupkg/
- tag: v$(appveyor_build_version)
- on:
- branch: master
+ - provider: NuGet
+ api_key:
+ secure: Fh92tRIFbe1FAiyD8lTThWgAorQ1vV+eFYMlUK0iLHBBenJcy/UYc1qj6kgHvUcO
+ skip_symbols: true
+ on:
+ branch: /^(main|dev)$/
+ - provider: GitHub
+ auth_token:
+ secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
+ artifacts:
+ /Serilog.*\.nupkg/
+ /Serilog.*\.snupkg/
+ tag: v$(appveyor_build_version)
+ on:
+ branch: main
+
\ No newline at end of file
diff --git a/assets/serilog-enricher-nuget.png b/assets/serilog-enricher-nuget.png
new file mode 100644
index 0000000..0a1173e
Binary files /dev/null and b/assets/serilog-enricher-nuget.png differ
diff --git a/serilog-enrichers-environment.sln b/serilog-enrichers-environment.sln
index 067362b..015fcea 100644
--- a/serilog-enrichers-environment.sln
+++ b/serilog-enrichers-environment.sln
@@ -8,9 +8,9 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
ProjectSection(SolutionItems) = preProject
Build.ps1 = Build.ps1
- NuGet.Config = NuGet.Config
README.md = README.md
assets\Serilog.snk = assets\Serilog.snk
+ appveyor.yml = appveyor.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{406006F7-12FA-4A8A-ADC8-80E5338F5275}"
diff --git a/src/Serilog.Enrichers.Environment/Enrichers/CachedPropertyEnricher.cs b/src/Serilog.Enrichers.Environment/Enrichers/CachedPropertyEnricher.cs
index a8097e4..a0ea129 100644
--- a/src/Serilog.Enrichers.Environment/Enrichers/CachedPropertyEnricher.cs
+++ b/src/Serilog.Enrichers.Environment/Enrichers/CachedPropertyEnricher.cs
@@ -15,32 +15,28 @@
using Serilog.Core;
using Serilog.Events;
-namespace Serilog.Enrichers
-{
- public abstract class CachedPropertyEnricher: ILogEventEnricher
- {
- private LogEventProperty _cachedProperty { get; set; }
+namespace Serilog.Enrichers;
- ///
- /// Enrich the log event.
- ///
- /// The log event to enrich.
- /// Factory for creating new properties to add to the event.
- public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
- {
- logEvent.AddPropertyIfAbsent(GetLogEventProperty(propertyFactory));
- }
+abstract class CachedPropertyEnricher: ILogEventEnricher
+{
+ LogEventProperty? CachedProperty { get; set; }
- private LogEventProperty GetLogEventProperty(ILogEventPropertyFactory propertyFactory)
- {
- // Don't care about thread-safety, in the worst case the field gets overwritten and one
- // property will be GCed
- if (_cachedProperty == null)
- _cachedProperty = CreateProperty(propertyFactory);
+ ///
+ /// Enrich the log event.
+ ///
+ /// The log event to enrich.
+ /// Factory for creating new properties to add to the event.
+ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
+ {
+ logEvent.AddPropertyIfAbsent(GetLogEventProperty(propertyFactory));
+ }
- return _cachedProperty;
- }
-
- protected abstract LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory);
+ LogEventProperty GetLogEventProperty(ILogEventPropertyFactory propertyFactory)
+ {
+ // Don't care about thread-safety, in the worst case the field gets overwritten and one
+ // property will be GCed
+ return CachedProperty ??= CreateProperty(propertyFactory);
}
+
+ protected abstract LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory);
}
diff --git a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentNameEnricher.cs b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentNameEnricher.cs
index 9bfd9de..82c68b2 100644
--- a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentNameEnricher.cs
+++ b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentNameEnricher.cs
@@ -15,37 +15,33 @@
using System;
using Serilog.Core;
using Serilog.Events;
-using System.Runtime.CompilerServices;
-namespace Serilog.Enrichers
+namespace Serilog.Enrichers;
+
+///
+/// Enriches log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable.
+///
+sealed class EnvironmentNameEnricher : CachedPropertyEnricher
{
///
- /// Enriches log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable.
+ /// The property name added to enriched log events.
///
- public class EnvironmentNameEnricher : CachedPropertyEnricher
+ const string EnvironmentNamePropertyName = "EnvironmentName";
+
+ protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
{
- ///
- /// The property name added to enriched log events.
- ///
- public const string EnvironmentNamePropertyName = "EnvironmentName";
+ var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
- // Qualify as uncommon-path
- [MethodImpl(MethodImplOptions.NoInlining)]
- protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
+ if (string.IsNullOrWhiteSpace(environmentName))
{
- var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
-
- if (string.IsNullOrWhiteSpace(environmentName))
- {
- environmentName = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
- }
-
- if (string.IsNullOrWhiteSpace(environmentName))
- {
- environmentName = "Production";
- }
+ environmentName = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
+ }
- return propertyFactory.CreateProperty(EnvironmentNamePropertyName, environmentName);
+ if (string.IsNullOrWhiteSpace(environmentName))
+ {
+ environmentName = "Production";
}
+
+ return propertyFactory.CreateProperty(EnvironmentNamePropertyName, environmentName);
}
-}
+}
\ No newline at end of file
diff --git a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentUserNameEnricher.cs b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentUserNameEnricher.cs
index f8a90c7..a1b9675 100644
--- a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentUserNameEnricher.cs
+++ b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentUserNameEnricher.cs
@@ -16,30 +16,24 @@
using Serilog.Core;
using Serilog.Events;
-namespace Serilog.Enrichers
+namespace Serilog.Enrichers;
+
+///
+/// Enriches log events with an EnvironmentUserName property containing [\].
+///
+sealed class EnvironmentUserNameEnricher : CachedPropertyEnricher
{
///
- /// Enriches log events with an EnvironmentUserName property containing [\].
+ /// The property name added to enriched log events.
///
- public class EnvironmentUserNameEnricher : CachedPropertyEnricher
- {
- ///
- /// The property name added to enriched log events.
- ///
- public const string EnvironmentUserNamePropertyName = "EnvironmentUserName";
+ const string EnvironmentUserNamePropertyName = "EnvironmentUserName";
- protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
- {
-#if ENV_USER_NAME
- var userDomainName = Environment.UserDomainName;
- var userName = Environment.UserName;
-#else
- var userDomainName = Environment.GetEnvironmentVariable("USERDOMAIN");
- var userName = Environment.GetEnvironmentVariable("USERNAME");
-#endif
- var environmentUserName = !string.IsNullOrWhiteSpace(userDomainName) ? $@"{userDomainName}\{userName}" : userName;
+ protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
+ {
+ var userDomainName = Environment.UserDomainName;
+ var userName = Environment.UserName;
+ var environmentUserName = !string.IsNullOrWhiteSpace(userDomainName) ? $@"{userDomainName}\{userName}" : userName;
- return propertyFactory.CreateProperty(EnvironmentUserNamePropertyName, environmentUserName);
- }
+ return propertyFactory.CreateProperty(EnvironmentUserNamePropertyName, environmentUserName);
}
-}
+}
\ No newline at end of file
diff --git a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentVariableEnricher.cs b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentVariableEnricher.cs
index a51afec..0ca0912 100644
--- a/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentVariableEnricher.cs
+++ b/src/Serilog.Enrichers.Environment/Enrichers/EnvironmentVariableEnricher.cs
@@ -15,35 +15,31 @@
using System;
using Serilog.Core;
using Serilog.Events;
-using System.Runtime.CompilerServices;
-namespace Serilog.Enrichers
+namespace Serilog.Enrichers;
+
+///
+/// Enriches log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable.
+///
+sealed class EnvironmentVariableEnricher : CachedPropertyEnricher
{
+ readonly string _envVarName;
+
///
- /// Enriches log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable.
+ /// The property name added to enriched log events.
///
- public class EnvironmentVariableEnricher : CachedPropertyEnricher
- {
- private readonly string _envVarName;
-
- ///
- /// The property name added to enriched log events.
- ///
- public string EnvironmentVariablePropertyName { get; }
+ string EnvironmentVariablePropertyName { get; }
- public EnvironmentVariableEnricher(string envVarName, string propertyName)
- {
- _envVarName = envVarName;
- EnvironmentVariablePropertyName = propertyName ?? envVarName;
- }
+ public EnvironmentVariableEnricher(string envVarName, string? propertyName)
+ {
+ _envVarName = envVarName;
+ EnvironmentVariablePropertyName = propertyName ?? envVarName;
+ }
- // Qualify as uncommon-path
- [MethodImpl(MethodImplOptions.NoInlining)]
- protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
- {
- var environmentVariableValue = Environment.GetEnvironmentVariable(_envVarName);
+ protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
+ {
+ var environmentVariableValue = Environment.GetEnvironmentVariable(_envVarName);
- return propertyFactory.CreateProperty(EnvironmentVariablePropertyName, environmentVariableValue);
- }
+ return propertyFactory.CreateProperty(EnvironmentVariablePropertyName, environmentVariableValue);
}
-}
+}
\ No newline at end of file
diff --git a/src/Serilog.Enrichers.Environment/Enrichers/MachineNameEnricher.cs b/src/Serilog.Enrichers.Environment/Enrichers/MachineNameEnricher.cs
index a580eda..55ff49e 100644
--- a/src/Serilog.Enrichers.Environment/Enrichers/MachineNameEnricher.cs
+++ b/src/Serilog.Enrichers.Environment/Enrichers/MachineNameEnricher.cs
@@ -15,34 +15,22 @@
using System;
using Serilog.Core;
using Serilog.Events;
-using System.Runtime.CompilerServices;
-#if NETSTANDARD1_3
-using System.Net;
-#endif
+namespace Serilog.Enrichers;
-namespace Serilog.Enrichers
+///
+/// Enriches log events with a MachineName property containing .
+///
+sealed class MachineNameEnricher : CachedPropertyEnricher
{
///
- /// Enriches log events with a MachineName property containing .
+ /// The property name added to enriched log events.
///
- public class MachineNameEnricher : CachedPropertyEnricher
- {
- ///
- /// The property name added to enriched log events.
- ///
- public const string MachineNamePropertyName = "MachineName";
+ const string MachineNamePropertyName = "MachineName";
- // Qualify as uncommon-path
- [MethodImpl(MethodImplOptions.NoInlining)]
- protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
- {
-#if NETSTANDARD1_3
- var machineName = Dns.GetHostName();
-#else
- var machineName = Environment.MachineName;
-#endif
- return propertyFactory.CreateProperty(MachineNamePropertyName, machineName);
- }
+ protected override LogEventProperty CreateProperty(ILogEventPropertyFactory propertyFactory)
+ {
+ var machineName = Environment.MachineName;
+ return propertyFactory.CreateProperty(MachineNamePropertyName, machineName);
}
-}
+}
\ No newline at end of file
diff --git a/src/Serilog.Enrichers.Environment/EnvironmentLoggerConfigurationExtensions.cs b/src/Serilog.Enrichers.Environment/EnvironmentLoggerConfigurationExtensions.cs
index 7e8d195..06a53bc 100644
--- a/src/Serilog.Enrichers.Environment/EnvironmentLoggerConfigurationExtensions.cs
+++ b/src/Serilog.Enrichers.Environment/EnvironmentLoggerConfigurationExtensions.cs
@@ -16,65 +16,64 @@
using Serilog.Configuration;
using Serilog.Enrichers;
-namespace Serilog
+namespace Serilog;
+
+///
+/// Extends to add enrichers for .
+/// capabilities.
+///
+public static class EnvironmentLoggerConfigurationExtensions
{
///
- /// Extends to add enrichers for .
- /// capabilities.
+ /// Enrich log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT
+ /// or DOTNET_ENVIRONMENT
environment variable.
///
- public static class EnvironmentLoggerConfigurationExtensions
+ /// Logger enrichment configuration.
+ /// Configuration object allowing method chaining.
+ public static LoggerConfiguration WithEnvironmentName(
+ this LoggerEnrichmentConfiguration enrichmentConfiguration)
{
- ///
- /// Enrich log events with a EnvironmentName property containing the value of the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT environment variable.
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithEnvironmentName(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
- return enrichmentConfiguration.With();
- }
+ if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
+ return enrichmentConfiguration.With();
+ }
- ///
- /// Enrich log events with a MachineName property containing the current .
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithMachineName(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
- return enrichmentConfiguration.With();
- }
+ ///
+ /// Enrich log events with a MachineName property containing the current .
+ ///
+ /// Logger enrichment configuration.
+ /// Configuration object allowing method chaining.
+ public static LoggerConfiguration WithMachineName(
+ this LoggerEnrichmentConfiguration enrichmentConfiguration)
+ {
+ if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
+ return enrichmentConfiguration.With();
+ }
- ///
- /// Enriches log events with an EnvironmentUserName property containing [\].
- ///
- /// Logger enrichment configuration.
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithEnvironmentUserName(
- this LoggerEnrichmentConfiguration enrichmentConfiguration)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
- return enrichmentConfiguration.With();
- }
+ ///
+ /// Enriches log events with an EnvironmentUserName property containing .
+ ///
+ /// Logger enrichment configuration.
+ /// Configuration object allowing method chaining.
+ public static LoggerConfiguration WithEnvironmentUserName(
+ this LoggerEnrichmentConfiguration enrichmentConfiguration)
+ {
+ if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
+ return enrichmentConfiguration.With();
+ }
- ///
- /// Enriches log events with an property containing the value of the specified Environment Variable using
- /// [\].
- ///
- /// Logger enrichment configuration.
- /// The name of the Environment Variable
- /// The Optional name of the property. If empty is used
- /// Configuration object allowing method chaining.
- public static LoggerConfiguration WithEnvironmentVariable(
- this LoggerEnrichmentConfiguration enrichmentConfiguration, string environmentVariableName, string propertyName = null)
- {
- if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
- var environmentVariableEnricher = new EnvironmentVariableEnricher(environmentVariableName, propertyName);
- return enrichmentConfiguration.With(environmentVariableEnricher);
- }
-
+ ///
+ /// Enriches log events with an property containing the value of the specified Environment Variable using
+ /// .
+ ///
+ /// Logger enrichment configuration.
+ /// The name of the Environment Variable
+ /// The Optional name of the property. If empty is used
+ /// Configuration object allowing method chaining.
+ public static LoggerConfiguration WithEnvironmentVariable(
+ this LoggerEnrichmentConfiguration enrichmentConfiguration, string environmentVariableName, string? propertyName = null)
+ {
+ if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration));
+ var environmentVariableEnricher = new EnvironmentVariableEnricher(environmentVariableName, propertyName);
+ return enrichmentConfiguration.With(environmentVariableEnricher);
}
-}
+}
\ No newline at end of file
diff --git a/src/Serilog.Enrichers.Environment/Properties/AssemblyInfo.cs b/src/Serilog.Enrichers.Environment/Properties/AssemblyInfo.cs
deleted file mode 100644
index e6a0a37..0000000
--- a/src/Serilog.Enrichers.Environment/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-using System;
-using System.Reflection;
-
-[assembly: AssemblyVersion("2.0.0.0")]
-
-[assembly: CLSCompliant(true)]
diff --git a/src/Serilog.Enrichers.Environment/Serilog.Enrichers.Environment.csproj b/src/Serilog.Enrichers.Environment/Serilog.Enrichers.Environment.csproj
index d2df974..ab003f8 100644
--- a/src/Serilog.Enrichers.Environment/Serilog.Enrichers.Environment.csproj
+++ b/src/Serilog.Enrichers.Environment/Serilog.Enrichers.Environment.csproj
@@ -1,39 +1,38 @@
-
- Enrich Serilog log events with properties from System.Environment.
- 2.3.0
- Serilog Contributors
- net45;netstandard1.3;netstandard1.5;netstandard2.0
- Serilog.Enrichers.Environment
- ../../assets/Serilog.snk
- true
- true
- Serilog.Enrichers.Environment
- serilog;machine;enricher
- http://serilog.net/images/serilog-enricher-nuget.png
- http://serilog.net
- Apache-2.0
- https://github.com/serilog/serilog-enrichers-environment
- git
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(DefineConstants);ENV_USER_NAME
-
-
+
+ Enrich Serilog log events with properties from System.Environment.
+ 3.0.0
+ 3.0.0.0
+ Serilog Contributors
+
+ net471;net462
+
+ $(TargetFrameworks);net8.0;net6.0;netstandard2.0
+ serilog;machine;enricher
+ serilog-enricher-nuget.png
+ https://github.com/serilog/serilog-enrichers-environment
+ Apache-2.0
+ https://github.com/serilog/serilog-enrichers-environment
+ git
+ true
+ Serilog
+ README.md
+ 12
+ enable
+ true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/test/Serilog.Enrichers.Environment.Tests/Serilog.Enrichers.Environment.Tests.csproj b/test/Serilog.Enrichers.Environment.Tests/Serilog.Enrichers.Environment.Tests.csproj
index 539f9eb..a48aa24 100644
--- a/test/Serilog.Enrichers.Environment.Tests/Serilog.Enrichers.Environment.Tests.csproj
+++ b/test/Serilog.Enrichers.Environment.Tests/Serilog.Enrichers.Environment.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1;net46
+ net48;net8.0
false
@@ -10,9 +10,9 @@
-
-
-
+
+
+
diff --git a/test/Serilog.Enrichers.Environment.Tests/Support/DelegateDisposable.cs b/test/Serilog.Enrichers.Environment.Tests/Support/DelegateDisposable.cs
index fbafd38..54bfc69 100644
--- a/test/Serilog.Enrichers.Environment.Tests/Support/DelegateDisposable.cs
+++ b/test/Serilog.Enrichers.Environment.Tests/Support/DelegateDisposable.cs
@@ -4,8 +4,8 @@ namespace Serilog.Tests.Support
{
public class DelegateDisposable : IDisposable
{
- private readonly Action _disposeAction;
- private bool _disposed;
+ readonly Action _disposeAction;
+ bool _disposed;
public DelegateDisposable(Action disposeAction)
{