While working on an Express.js application recently, I faced the need to log all requests passing through it. For years, I've been a loyal user of morgan, a popular HTTP request middleware logger for Node.js.
However, morgan hasn't seen any updates in the past four years. It was high time for a change! So, I decided to try out express-requests-logger, a more current logging middleware.
Getting express-requests-logger up and running is straightforward. Here's how I did it:
Next, I integrated it into my application:
One feature I absolutely love is doubleAudit
. This logs incoming requests and their corresponding responses. It's incredibly useful for monitoring the full lifecycle of requests, especially when debugging complex interactions.
With frequent health check calls from Kubernetes on certain endpoints, my logs were getting cluttered. The excludeURLs
feature came to the rescue, allowing me to exclude these endpoints from logging and keep my log output clean and relevant.
Express-requests-logger offers several options for enhancing security and privacy in logs:
These features are crucial for maintaining compliance with data protection regulations and ensuring that sensitive information stays secure.
The flexibility to integrate a custom logger is a win for me. I use winston
for logging because of its versatility and performance. Express-requests-logger allows me to continue using winston
seamlessly, which keeps my setup consistent and efficient.
I highly recommend giving express-requests-logger a try!