Hi,
I saw this issue for overriding the default logging / altering the log statements emitted when doing requests using a HttpClientFactory based HttpClient, which recommends re-implementing the IHttpMessageHandlerBuilderFilter for this.
I wanted 2 alterations from the default logging, to reduce the logs:
- Don't emit 2 log statements for each request, but only one (the default logging emits a start-req, and a end-req log statement)
- In the single emitted log statement, include the request url.
So reducing this:
- "Sending HTTP request {HttpMethod} {Uri}");
- "Received HTTP response headers after {ElapsedMilliseconds}ms - {StatusCode}"
to
- $"{HttpMethod} {Uri} - {StatusCode} in {ElapsedMilliseconds}ms"
I was surprised by the amount of code I had to write to be able to do this. Is there no easier way to just modify the default log statements..?
Hi,
I saw this issue for overriding the default logging / altering the log statements emitted when doing requests using a HttpClientFactory based HttpClient, which recommends re-implementing the
IHttpMessageHandlerBuilderFilterfor this.I wanted 2 alterations from the default logging, to reduce the logs:
So reducing this:
to
I was surprised by the amount of code I had to write to be able to do this. Is there no easier way to just modify the default log statements..?