Skip to content

AspNetCore Middleware for Logging HTTP Request and Response

Notifications You must be signed in to change notification settings

Hiblet/LogRequestAndResponseMiddleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

LogRequestAndResponseMiddleware

Description

This class is an AspNetCore middleware class to log the request and response data for an HTTP request. [Middleware is a component that makes up the HTTP processing pipeline in AspNetCore.]

Contents

LogRequestAndResponseMiddleware.cs

A single file, containing a single class. The class takes an injected logger object, and attempts to log using that object, so this will work with any logger implementing Microsoft.Extensions.Logging.ILogger type interfaces.

Installation

Use in an AspNetCore project as per other Middleware.

Usage

Amend the Configure() function in the Startup class to include, somewhere near the start of the pipeline...

     app.UseMiddleware<NZ01.LogRequestAndResponseMiddleware>();

Contributing

Bug reports, suggestions all welcome, pull requests etc.
Function bloat should be avoided.

Credits

This work is drawn from several sources, and attempts to unify the approaches. Additionally, this class prevents exceptions that occur for cached static files.

License

Attribution-ShareAlike 4.0 International

  • If this code is forked and adapted, please publish and share the improvements if it does not break IP restrictions.
  • Use is welcome in commercial code, but if you wish to pay back something, please donate to Second Chance Tasman Dogs Home, or better still, adopt a Rescue Dog and make the world a slightly less awful place. https://secondchanceadoptadog.com

About

AspNetCore Middleware for Logging HTTP Request and Response

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages