AmazonCloudWatchLogs.DescribeLogGroupsAsync() is not working nor throwing any errors when invoked

0

Call to AmazonCloudWatchLogs.DescribeLogGroupsAsync() is not working nor throwing any errors when invoked.

1] Can you please share more inputs to resolve this issue / get errors logged for this call [or all AWS .NET API calls]?

2] Is there any additional settings / configurations we need to do so that error / catch block is invoked so we get logs about it?

We want to send logs to AWS CloudWatch for our internal/on-premise web application [this is actually hosted on internal cloud & .NET + Angular Web application] So we are using AWS .NET API i.e. AmazonCloudWatchLogs.DescribeLogGroupsAsync() & other related classes. We have wrapped call to this function with try catch block along with proper logging at all lines including catch block error logging but we are not getting any logs post call to AmazonCloudWatchLogs.DescribeLogGroupsAsync() & also logs in catch block also not invoked.

Below is sample code

For reference,

1] we only get logs till - _consoleLogger.LogInformation("Logger ctor - Calling DescribeLogGroupsAsync Start"); 2] & also log statement in catch block are not invoked.

Sample Code -

try
            {
                _consoleLogger.LogInformation("Logger ctor - Calling DescribeLogGroupsAsync Start");
                var existingLogGroups = _client.DescribeLogGroupsAsync();
                var result = existingLogGroups.ConfigureAwait(true).GetAwaiter().GetResult();
                _consoleLogger.LogInformation($"Logger ctor - NextToken is {result.NextToken}");
                _consoleLogger.LogInformation("Logger ctor - Calling DescribeLogGroupsAsync End");

                Initialise(_consoleLogger).Wait();
            }
            catch (AggregateException exception)
            {
                foreach (var inner in exception.InnerExceptions)
                {
                    _consoleLogger.LogError(inner, $"Logger ctor - AggregateException occured in Logger ctor");
                }
            }
            catch (Exception exception)
            {
                _consoleLogger.LogError(exception, $"Logger ctor - Exception occured in Logger Ctor");
            }
1개 답변
0

I would recommend not using GetAwaiter().GetResult() to avoid thread exhaustion and deadlock. Instead, simply write, var result= await _client.DescribeLogGroupsAsync(); You can see an example here -https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/dotnetv3/CloudWatchLogs/DescribeLogGroupsExample/DescribeLogGroups.cs

AWS
maykums
답변함 일 년 전
  • Thanks. Initially, I had used both await _client.DescribeLogGroupsAsync() & also _client.DescribeLogGroupsAsync().Wait(), but not solution & still its not working.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠