Improve discoverability of DI prerequisites in AspNetCore.Diagnostics.Middleware package
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
Similar to #4675.
Currently if you want to enable either HttpLogging enrichment or redaction you have to know that you need to reference `Microsoft.Extensions.Compliance.Redaction` package and register `AddRedaction()` in the `IServiceCollection`. If you don't do that you'll get an exception saying that service container cannot find `IRedactorProvider`. As a solution, we can make `IRedactorProvider` optional, and use `NullRedactor` when it is not registered.
Another issue is that `AddHttpLogEnricher` in addition to registering HttpLogEnricher registers redaction. It could be unobvious from user's perspective. For example, a user registers only HttpLogEnricher and he/she doesn't expect that it will require `IRedactorProvider`, but the package will and during start up the application will throw the exception mentioned above.
Contributor guide
Assessment
This issue has not been assessed yet.