Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnkors/minimalhttplogger
Reduces no. of HttpClient log statements from 4 to 1 pr request (Microsoft.Extensions.Http)
https://github.com/johnkors/minimalhttplogger
dotnet dotnet-core extensions httpclient logging
Last synced: about 2 months ago
JSON representation
Reduces no. of HttpClient log statements from 4 to 1 pr request (Microsoft.Extensions.Http)
- Host: GitHub
- URL: https://github.com/johnkors/minimalhttplogger
- Owner: johnkors
- License: mit
- Created: 2021-12-08T09:30:52.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-15T22:34:57.000Z (about 1 year ago)
- Last Synced: 2024-12-02T04:13:29.227Z (about 2 months ago)
- Topics: dotnet, dotnet-core, extensions, httpclient, logging
- Language: C#
- Homepage:
- Size: 62.5 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# MinimalHttpLogger
[![Build](https://github.com/johnkors/MinimalHttpLogger/workflows/CI/badge.svg)](https://github.com/johnkors/MinimalHttpLogger/actions)
[![NuGet](https://img.shields.io/nuget/v/MinimalHttpLogger.svg)](https://www.nuget.org/packages/MinimalHttpLogger/)
[![NuGet](https://img.shields.io/nuget/dt/MinimalHttpLogger.svg)](https://www.nuget.org/packages/MinimalHttpLogger/)## Why?
My logs were
* hard to read
* filling up space(*)## What is this?
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:
1. Reduces the number of log statements on httpclient requests from 4 to 1
2. Logs 1 aggregated log statement: `{Method} {Uri} - {StatusCode} {StatusCodeLiteral} in {Time}ms`### Change in output
Before:
```log
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:
```log
info: GET https://www.google.com/ - 200 OK in 186.4883ms
```## Install
```sh
$ dotnet add package MinimalHttpLogger
```## Usage
```csharp
services.UseMinimalHttpLogger();
```---
(*) I'm cheap. My Papertrail account stops logging when reaching a certain szie, so reducing the log helps