Giter Site home page Giter Site logo

tarafdarmansour / requestlogger-aspnetcore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotnetzoom/requestlogger-aspnetcore

0.0 0.0 0.0 773 KB

Log Request and Response Details of your Actions in ASP.NET Core.

C# 84.17% HTML 11.15% CSS 4.00% JavaScript 0.67%

requestlogger-aspnetcore's Introduction

RequestLogger

Log Request and Response Details of your Actions in ASP.NET Core.

Log Details

  • Execution date time (TimeStamp)
  • Execution duration (Elapsed)
  • Action Arguments (like your ViewModels)
  • ModelState (IsValid and Errors)
  • Request Path (Host and QueryString and RouteValues)
  • Request Method
  • Request Cookies
  • Request Headers
  • User.Identity (UserName and IsAuthenticated and Claims)
  • Response Cookies
  • Response Headers
  • Response StatusCode
  • IpAddress
  • UrlReferrer
  • Exception if thrown

You can add your desired details like UserAgent info (such as browser, os, ... details) in LogRequestAttribute.OnActionExecuting

Usage

Just put [LogRequest] attribute on your actions or register it globally

public class HomeController : Controller
    {
        public HomeController()
        {
        }

        [LogRequest]
        public IActionResult Index(MyViewModel myViewModel)
        {
            return View();
        }

        [LogRequest]
        public IActionResult Privacy()
        {
            throw new Exception("test");
            return View();
        }
    }

Check out Program.cs and Startup.cs to see how to Configuration.

This uses Serilog and Serilog.AspNetCore for logging and MSSqlServer sink but you can use any other Sinks.

ScreenShot

Image

requestlogger-aspnetcore's People

Contributors

mjebrahimi avatar dependabot-preview[bot] avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.