I have a project that calls many rest APIs from other projects, and I have some problems to identify not only errors from those APIs but also correct responses but the information is not correct on the other system. I did this part, but it only log the retry and I need to log the success also.
services.AddHttpClient<IClient, Client>("AuthClient", x =>
{
x.BaseAddress = new Uri(urlAn);
}).AddPolicyHandler((services, request) =>
HttpPolicyExtensions.HandleTransientHttpError().WaitAndRetryAsync(
new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(10)
},
onRetry: (outcome, timespan, retryAttempt, context) =>
{
services.GetService<ILogger>()
.LogWarning("Delaying for {delay}ms, then making retry {retry}.", timespan.TotalMilliseconds, retryAttempt);
}));