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 年前檢視次數 250 次
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
已回答 1 年前
  • Thanks. Initially, I had used both await _client.DescribeLogGroupsAsync() & also _client.DescribeLogGroupsAsync().Wait(), but not solution & still its not working.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南