diff --git a/src/NLog.Targets.Splunk/Splunk.Logging.Common/HttpEventCollectorResendMiddleware.cs b/src/NLog.Targets.Splunk/Splunk.Logging.Common/HttpEventCollectorResendMiddleware.cs index 3cdc169..3618916 100644 --- a/src/NLog.Targets.Splunk/Splunk.Logging.Common/HttpEventCollectorResendMiddleware.cs +++ b/src/NLog.Targets.Splunk/Splunk.Logging.Common/HttpEventCollectorResendMiddleware.cs @@ -115,6 +115,8 @@ public async Task Plugin( } if (statusCode != HttpStatusCode.OK || webException != null) { + // when splunk connectivity is failed then set status to failed.This status help to switch target in nlog config file + GlobalDiagnosticsContext.Set("splunkstatus", "failed"); throw new HttpEventCollectorException( code: statusCode == HttpStatusCode.OK ? HttpStatusCode.InternalServerError : statusCode, webException: webException, @@ -123,7 +125,11 @@ public async Task Plugin( serializedEvents: System.Text.Encoding.UTF8.GetString(serializedEvents) ); } + else{ + // when splunk connectivity is failed then set status to failed + GlobalDiagnosticsContext.Set("splunkstatus", "success"); + } return response; } } -} \ No newline at end of file +} diff --git a/src/build-nuget-packages.ps1 b/src/build-nuget-packages.ps1 index 29d4e7c..c728412 100644 --- a/src/build-nuget-packages.ps1 +++ b/src/build-nuget-packages.ps1 @@ -4,6 +4,8 @@ Param( ) cd .\NLog.Targets.Splunk Write-Output "Building release $versionSuffix nuget packages..." +Write-Output "Restoring NuGet packages..." +dotnet restore dotnet pack --configuration Release --include-symbols --version-suffix $versionSuffix Write-Output "Moving $versionSuffix nuget packages to releases folder..." Move-Item .\bin\Release\*.nupkg ..\..\releases -Force