Skip to content

[Feature request]: Conditionally set log levels for specific resilience policy #2090

@GordonSo

Description

@GordonSo

Is your feature request related to a specific problem? Or an existing feature?

existing feature

Currently, when the rate-limiting threshold is reached, Polly would log an error log:

Resilience event occurred. EventName: ‘“OnRateLimiterRejected”‘, Source: ‘“url/RateLimit”/“url/RateLimit”/“ratelimited”‘, Operation Key: ‘“operation_key”’, Result: ‘null’

This is an expected behaviour in our use case, and we would like to suppress this error log -> warning, without suppressing all other logs from the library.

Our current solution is to bump the log level for the entire to be "warning" -> "fatal" at the .net logging configuration e.g.
image

The request would be to suppress only the "OnRateLimiterRejected" to "warning".

Describe the solution you'd like

We found that the log is hardcoded to be ResilienceEventSeverity.Error, here:
https://github.com/App-vNext/Polly/blob/main/src/Polly.RateLimiting/RateLimiterResilienceStrategy.cs#L61

The initial idea is to extend the policy, so we can initialise the pipeline with an optional parameter for the overriding log.level.

If this option sounds feasible, we can start digging further and maybe help raise a PR...

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions