https://github.com/dotnetzoom/requestlogger-aspnetcore
Log Request and Response Details of your Actions in ASP.NET Core.
https://github.com/dotnetzoom/requestlogger-aspnetcore
asp-net-core aspnet-core aspnetcore logger logging request-logger request-logging requestlogger requestlogging response-logger response-logging serilog
Last synced: 20 days ago
JSON representation
Log Request and Response Details of your Actions in ASP.NET Core.
- Host: GitHub
- URL: https://github.com/dotnetzoom/requestlogger-aspnetcore
- Owner: dotnetzoom
- Created: 2020-07-14T05:59:32.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-15T12:44:34.000Z (over 1 year ago)
- Last Synced: 2024-01-15T16:29:04.690Z (over 1 year ago)
- Topics: asp-net-core, aspnet-core, aspnetcore, logger, logging, request-logger, request-logging, requestlogger, requestlogging, response-logger, response-logging, serilog
- Language: C#
- Homepage:
- Size: 757 KB
- Stars: 19
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```csharp
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`](https://github.com/dotnetzoom/RequestLogger-AspNetCore/blob/master/RequestLogger/Program.cs) and [`Startup.cs`](https://github.com/dotnetzoom/RequestLogger-AspNetCore/blob/master/RequestLogger/Startup.cs) to see how to Configuration.
This uses [Serilog](https://github.com/serilog/serilog) and [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore) for logging and [MSSqlServer](https://github.com/serilog/serilog-sinks-mssqlserver) sink but you can use any other [Sinks](https://github.com/serilog/serilog/wiki/Provided-Sinks).
## ScreenShot
