Net.CrossCutting.RequestLogger 1.0.4

Package Description

Install-Package Net.CrossCutting.RequestLogger -Version 1.0.4
dotnet add package Net.CrossCutting.RequestLogger --version 1.0.4
<PackageReference Include="Net.CrossCutting.RequestLogger" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Net.CrossCutting.RequestLogger --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Net.CrossCutting.RequestLogger

Handle Cross-Cutting conserns via the power of Asp.net-core middelwares.

RequestLogger make it possible to log each http request and it related response to multiple data source (DB or file for example).

At the beginning you need to config RequestLogger, this is requierd because we need to fetch some dynamic settings at start point. To achieve that add a new json properties named RequestLog to your appseting.josn file.

{
  "RequestLogger": {
    "Status": true,
    //file,sqlserver
    "Provider": "sqlserver",
    "FilePath": "logs/requests/reqlog-.txt",
    "SqlServerConnectionString": "Data Source=SQL-SRV\\SQL2017;Initial Catalog=Logs;User ID=sa;Password=admin",
    "SqlServerTableName": "RequestLog"
  }
}

Then edit your startup and ConfigureServices methods (composition root of your Dependency Injection Startup.cs file by default) as below.

private RequestLogSetting requestLogSetting;

public Startup(IConfiguration configuration)
{
    //...
    requestLogSetting = Configuration.GetSection("RequestLogger").Get<RequestLogSetting>();
    //...
}

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddSingleton<IRequestLogSetting>(requestLogSetting);
    //...
}

Finally edit your Configure method. This tell .net core runtime to inject RequestLogger middelware to its pipeline.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    //Sample 1: Log all recieved requests
    appBuilder.UseRequestLoggerMiddleware();    
    //...
}
}

Also you can filter the routing of middelware as you want like the following example. In this example the middelware logs all recieved requests when incomming http requests started with '/api'.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"), appBuilder =>
    {
        appBuilder.UseRequestLoggerMiddleware();
    });
    //...
}

Net.CrossCutting.RequestLogger

Handle Cross-Cutting conserns via the power of Asp.net-core middelwares.

RequestLogger make it possible to log each http request and it related response to multiple data source (DB or file for example).

At the beginning you need to config RequestLogger, this is requierd because we need to fetch some dynamic settings at start point. To achieve that add a new json properties named RequestLog to your appseting.josn file.

{
  "RequestLogger": {
    "Status": true,
    //file,sqlserver
    "Provider": "sqlserver",
    "FilePath": "logs/requests/reqlog-.txt",
    "SqlServerConnectionString": "Data Source=SQL-SRV\\SQL2017;Initial Catalog=Logs;User ID=sa;Password=admin",
    "SqlServerTableName": "RequestLog"
  }
}

Then edit your startup and ConfigureServices methods (composition root of your Dependency Injection Startup.cs file by default) as below.

private RequestLogSetting requestLogSetting;

public Startup(IConfiguration configuration)
{
    //...
    requestLogSetting = Configuration.GetSection("RequestLogger").Get<RequestLogSetting>();
    //...
}

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddSingleton<IRequestLogSetting>(requestLogSetting);
    //...
}

Finally edit your Configure method. This tell .net core runtime to inject RequestLogger middelware to its pipeline.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    //Sample 1: Log all recieved requests
    appBuilder.UseRequestLoggerMiddleware();    
    //...
}
}

Also you can filter the routing of middelware as you want like the following example. In this example the middelware logs all recieved requests when incomming http requests started with '/api'.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseWhen(context => context.Request.Path.StartsWithSegments("/api"), appBuilder =>
    {
        appBuilder.UseRequestLoggerMiddleware();
    });
    //...
}

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.4 132 10/29/2018
1.0.3 116 10/29/2018
1.0.1 135 10/29/2018