scombroid / Scombroid.AspNetCore.HttpLogbook

ASP.NET Core http request and response logging

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scombroid.AspNetCore.HttpLogbook

A library to provide logging for ASP.NET Core http request and response

Get Started

Install the latest version from NuGet

Install-Package Scombroid.AspNetCore.HttpLogbook

Usage

Add the following code to the ConfigureServices(...)

	services
		.AddHttpLogbook(Configuration.GetSection("HttpLogbook"))
		.AddLogger<MyHttpLogbookLogger>();

Add the following code to the Configure(...)

  app.UseLogbook();

Example Configuration

"HttpLogbook": {
    "Paths": {
      "*": {
        "Methods": {
          "*": {
            "Request": {
              "LogLevel": "Information"
            },
            "Response": {
              "LogLevel": "Information"
            }
          }
        }
      },      
      "/weatherforecast": {
        "Methods": {
          "GET": {
            "Request": {
              "LogLevel": "Information"
            },
            "Response": {
              "LogLevel": "None"
            }
          },
          "POST": {
            "Request": {
              "LogLevel": "Trace"
            },
            "Response": {
              "LogLevel": "Information"
            }
          }
        }
      }
    }
  }

About

ASP.NET Core http request and response logging


Languages

Language:C# 100.0%