I've created a http client in asp.net core3.1. And injected it in via startup and it works fine.
services.AddHttpClient<MyClient>();
However I can't control it's logging output. Been following the advice here https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1#logging
I've tried all sorts in my config. It currently looks like this
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning",
"System": "Error",
"System.Net.Http": "Warning",
"System.Net.Http.HttpClient": "Warning",
"System.Net.Http.HttpClient.MyClient.LogicalHandler": "Warning",
"System.Net.Http.HttpClient.MyClient.ClientHandler": "Warning",
"Microsoft.AspNetCore.Hosting": "Warning",
"Microsoft.Hosting.Lifetime": "Warning"
}
},
But I keep getting the infomation logs e.g.
Level":"Information","MessageTemplate":"Received HTTP response after {ElapsedMilliseconds}ms - {StatusCode}","Properties":{"ElapsedMilliseconds":895.4859,"StatusCode":"UnprocessableEntity","EventId":{"Id":101,"Name":"RequestEnd"}
"Level":"Information","MessageTemplate":"End processing HTTP request after {ElapsedMilliseconds}ms - {StatusCode}","Properties":{"ElapsedMilliseconds":932.1484,"StatusCode":"UnprocessableEntity","EventId":{"Id":101,"Name":"RequestPipelineEnd"}
The sourcecontext is logging too. And this logs as "SourceContext":"System.Net.Http.HttpClient.MyClient.ClientHandler" which rules out a typing issue in my view