dotnet / dotnet/dotnet-api-docs

Documentation is incomplete in terms of how to actually use these extension methods

Open
#11,373 1 comment 0 reactions 0 assignees View on GitHub
area-Extensions-DependencyInjection untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Missing information

### Description

The `AddExtendedHttpClientLogging` extension method seems to be used to add a `IHttpClientAsyncLogger`. It also seems the only way to control the `LoggingOptions`. However simply calling this extension method results in a runtime error `Unable to resolve service for type 'Microsoft.Extensions.Compliance.Redaction.IRedactorProvider' while attempting to activate 'Microsoft.Extensions.Http.Diagnostics.HttpRouteParser'`. There appears to be more extension methods that need to be called first.

To test this I did the following.

```csharp
services.AddHttpCLient(client => { ... })
.AddLogger(false)
.AddExtendedHttpClientLogging(config => { ... });
```

It is unclear what purpose this extension serves beyond being able to configure logging options, if it worked. My logger implements `IHttpClientAsyncLogger` and it is properly called just by using `AddLogger`.

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.httpclientloggingservicecollectionextensions.addextendedhttpclientlogging?view=net-9.0-pp

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/Microsoft.Extensions.DependencyInjection/HttpClientLoggingServiceCollectionExtensions.xml

### Document Version Independent Id

1952876e-6a96-8953-9511-1d832671cbe2

### Platform Id

8d4b44df-46b2-76de-8220-640554158f99

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.