https://github.com/a-postx/delobytes.aspnetcore.logging
Прослойки логирования для веб-апи приложений.
https://github.com/a-postx/delobytes.aspnetcore.logging
Last synced: 4 days ago
JSON representation
Прослойки логирования для веб-апи приложений.
- Host: GitHub
- URL: https://github.com/a-postx/delobytes.aspnetcore.logging
- Owner: a-postx
- License: mit
- Created: 2021-09-16T07:40:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-01T11:16:23.000Z (almost 3 years ago)
- Last Synced: 2025-09-29T03:16:31.161Z (10 months ago)
- Language: C#
- Homepage:
- Size: 64.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
- License: LICENSE
Awesome Lists containing this project
README
# Delobytes.AspNetCore.Logging
Logging middlewares for web-API apps.
[RU](README.md), [EN](README.en.md)
## NetworkLoggingMiddleware
You can use network logging middleware to add IP-address property to the logging context.
**Usage**
```csharp
public void Configure(IApplicationBuilder application)
{
application.UseNetworkLogging();
}
```
## ClaimsLoggingMiddleware
You can use network claims logging middleware to add user claims properties to the logging context.
**Usage**
```csharp
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddAuthenticationCore();
services.AddClaimsLogging(options =>
{
options.ClaimNames = new [] { "CustomClaimToLog" };
});
}
public void Configure(IApplicationBuilder application)
{
application
.UseAuthentication()
.UseClaimsLogging();
}
```
## HttpContextLoggingMiddleware
You can use HTTP context logging middleware to log detailed request and response properties in additional log messages.
**Usage**
```csharp
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddHttpContextLogging(options =>
{
options.LogRequestBody = true;
options.LogResponseBody = true;
options.MaxBodyLength = 32759;
options.SkipPaths = new List { "/metrics" };
options.SkipRequestHeaders = new List { "Authorization" };
});
}
public void Configure(IApplicationBuilder application)
{
application
.UseRouting()
.UseHttpContextLogging();
}
```
## IdempotencyLoggingMiddleware
You can use idempotency logging middleware to add idempotency key header to the logging context.
**Usage**
```csharp
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddIdempotencyContextLogging(options =>
{
options.IdempotencyLogAttribute = "IdempotencyKey";
});
}
public void Configure(IApplicationBuilder application)
{
application.UseIdempotencyContextLogging();
}
```
## License
[MIT](https://github.com/a-postx/Delobytes.AspNetCore.Logging/blob/master/LICENSE)