Courses / Node.js
13. Custom middleware for logging
Implement a small middleware that logs requests and response times.
1 min read Chapter 13 of 48
JavaScript
Custom middleware for logging
Code that runs between an HTTP request and your route handler to log details and measure response time.
"I want to see which requests are slow and why, without sprinkling console.log everywhere."
A middleware function intercepts incoming requests, records start time, lets the request proceed, then logs method, URL, status, and elapsed time when the response finishes.
"I want to see which requests are slow and why, without sprinkling console.log everywhere."
A middleware function intercepts incoming requests, records start time, lets the request proceed, then logs method, URL, status, and elapsed time when the response finishes.