How do you log properly in a production Node app?

Node.js testing, performance and deployment · Freshers and experienced

Model answer

Use a structured logger such as pino or winston that writes JSON with levels and request ids, log errors with context, and never log passwords, tokens or personal data. Send logs to files or a log service with rotation, and use morgan or similar for access logs.

Learn this topic

Deploy a MERN App to a VPS with pm2, nginx and HTTPS (Let's Encrypt) in the course MERN Stack Full Course: MongoDB, Express, React and Node.js.

Sign in to add your own answer.

More questions