-
Notifications
You must be signed in to change notification settings - Fork 1
RequestLogger
This tool lets you view all requests made to the Cloud Debugger application. It logs not only HTML page requests but also internal requests, authentication, health checks, and other requests.
The tool captures and logs the headers and body of each request and response.
Two components handle the logging of request and response details:
- Custom HttpLogging Middleware
- Custom Middleware to Capture the Request Body
- The middleware is based on the ASP.NET Core Http Logging middleware, but we converted it into a custom class library. To avoid any collisions, the namespace was changed to Microsoft.AspNetCore.MyHttpLogging.
- We added custom code (found in the
CustomCode
folder) to log each request received. The middleware retains the latest 50 requests in memory. - All logs are written to a custom ILogger, named RequestLogger. From the Cloud Debugger, these logs can be queried and displayed on the screen.
- The request and response bodies are truncated if they exceed 5000 characters.
The UseRequestBodyCapture
middleware is a helper middleware that captures the raw request body and stores it in the HttpContext.Items
dictionary. This allows the custom HttpLogging middleware to access it later for logging.
To prevent the logs from becoming overloaded, the following requests are ignored:
/favicon.ico
/robots.txt
/requestlog/*
Additionally, requests for files with the following extensions are ignored:
.css
, .js
, .png
, .jpg
, .jpeg
, .gif
, .ico
, .svg
, .woff
, .woff2
, .ttf
, .eot
, .map
This filtering is handled by the RequestLog
class in the MyHttpLogging
class library.