Quantcast
Channel: Active questions tagged retry-logic - Stack Overflow
Viewing all articles
Browse latest Browse all 950

How can I suppress Execution Attempt log when using Polly V8 ResiliencePipelineBuilder?

$
0
0

In a .NET 8 project I'm using Serilog and Polly V8 and with ResiliencePipelineBuilder, and this log shows always, even if there is no retry:

Execution attempt. Source: 'screenshot-stream-with-retries/(null)/Retry', Operation Key: 'null', Result: 'System.IO.MemoryStream', Handled: 'false', Attempt: '0', Execution Time: '730.3186'

Here is my code:

public class ScreenshotStreamWithRetries{    private readonly ILogger<ScreenshotStreamWithRetries> _logger;    public ScreenshotStreamWithRetries(ILogger<ScreenshotStreamWithRetries> logger)    {        _logger = logger;    }    public static string Name => "screenshot-stream-with-retries";    public ResiliencePipelineBuilder<Stream> Configure(ResiliencePipelineBuilder<Stream> pipelineBuilder)    {        return pipelineBuilder.AddRetry(new RetryStrategyOptions<Stream>        {            MaxRetryAttempts = 3,            Delay = TimeSpan.FromSeconds(2),            BackoffType = DelayBackoffType.Exponential,            ShouldHandle = new PredicateBuilder<Stream>()                .Handle<Exception>(),            OnRetry = retryArguments =>            {                               _logger.LogWarning($"Screenshot failed with exception {retryArguments.Outcome.Exception.Message}. " +                             $"Waiting {retryArguments.Duration} before next retry. Retry attempt {retryArguments.AttemptNumber}");                return ValueTask.CompletedTask;            }        });    }}

I found this in Polly V8 source code https://github.com/App-vNext/Polly/blob/main/src/Polly.Extensions/Telemetry/Log.cs

I'd like to suppress a log that's creating unnecessary clutter. Can it be done?


Viewing all articles
Browse latest Browse all 950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>