AWS cloudwatch throws ResourceNotFoundException when removing active Log Streams

636 views Asked by At

I am using NLog to logging to cloud watch from my application (.net core 3.1), this issue happens when I have cleared some log streams so it keeps throwing the exception.

Exception: Amazon.CloudWatchLogs.Model.ResourceNotFoundException as The specified log stream does not exist and it is writing without any limit in NLog internal log file. I can get it working by stop & restart the application that time it will create a new log stream but I don't think that is a proper solution any help would be appreciated

Exception: Amazon.CloudWatchLogs.Model.ResourceNotFoundException: The specified log stream does not exist.
 ---> Amazon.Runtime.Internal.HttpErrorResponseException: Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.
   at Amazon.Runtime.HttpWebRequestMessage.GetResponseAsync(CancellationToken cancellationToken)
   at Amazon.Runtime.Internal.HttpHandler`1.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.Unmarshaller.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
   --- End of inner exception stack trace ---
   at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)
   at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)
   at Amazon.Runtime.Internal.ErrorHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.ErrorCallbackHandler.InvokeAsync[T](IExecutionContext executionContext)
   at Amazon.Runtime.Internal.MetricsHandler.InvokeAsync[T](IExecutionContext executionContext)
   at AWS.Logger.Core.AWSLoggerCore.SendMessages(CancellationToken token)
   at AWS.Logger.Core.AWSLoggerCore.Monitor(CancellationToken token)
  • Build Version: AWS.Logger.NLog 1.5.2 , NLog 4.7.2,NLog.Web.AspNetCore4.9.2
  • OS Info: Windows 10
  • Build Environment: Visual Studio 2019
  • Targeted .NET Platform: .NET Core 3.1
1

There are 1 answers

0
Rolf Kristensen On BEST ANSWER

AWS.Logger.NLog ver. 2.0.1 has now been released, with better handling of ResourceNotFoundException :

https://www.nuget.org/packages/AWS.Logger.NLog/

See also: https://github.com/aws/aws-logging-dotnet/issues/134