My logs were
- hard to read
- filling up space(*)
It's not possible to configure the log pattern of the Microsoft.Extensions.Http based HttpClient loggers. To modify, one has to replace them. This package replaces the default loggers with a logger that:
- Reduces the number of log statements on httpclient requests from 4 to 1
- Logs 1 aggregated log statement:
{Method} {Uri} - {StatusCode} {StatusCodeLiteral} in {Time}ms
Before:
info: Start processing HTTP request GET https://www.google.com/
info: Sending HTTP request GET https://www.google.com/
info: Received HTTP response headers after 188.6041ms - 200
info: End processing HTTP request after 188.8026ms - 200
After:
info: GET https://www.google.com/ - 200 OK in 186.4883ms
$ dotnet add package MinimalHttpLogger
services.UseMinimalHttpLogger();
(*) I'm cheap. My Papertrail account stops logging when reaching a certain szie, so reducing the log helps