AI Workshop: learn to build apps with AI →
Tips: Logging all the requests coming through an Express app

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


I needed to log all the requests coming into my Express app in a simple way: log them to the console.

No time (and no need) for more complex setups.

So I installed express-requests-logger

npm install express-requests-logger

Import it in your Node app:

import audit from 'express-requests-logger'

and added that as a middleware to my Express app:

app.use(audit())

Done!

You can also do

app.use((req, res, next) => {
  console.log(req);
  next();
});

but express-requests-logger has lots of options, formatting and filters you can use without reinventing the wheel.

Lessons in this unit:

0: Introduction
1: Axios crashes the Node.js process when the request fails
2: How to set up a cron job that runs a Node.js app
3: How to get both parsed body and raw body in Express
4: Interact with the Google Analytics API using Node.js
5: How to bulk convert file names using Node.js
6: How to deep copy JavaScript objects using structuredClone
7: How to handle file uploads in Node.js
8: How to send an email using nodemailer
9: ▶︎ Logging all the requests coming through an Express app
10: How to upload an image to S3 using Node.js
11: How to read a CSV file with Node.js
12: How to set the current working directory of a Node.js program
13: How to upload files to S3 from Node.js
14: How to write a CSV file with Node.js
15: Where to host a Node.js app
16: Parsing JSON with Node.js
17: nodemailer, how to embed an image into an email
18: The Pug Guide
19: Restarting a Node process without file changes
20: How to use Sequelize to interact with PostgreSQL