Logging

The Express server, ./lib/express/index.js, uses the logger middleware for logging. The Express logger should only be used in development. In fact, in a production environment, this will seriously impact performance as console functions are synchronous. Let's change the Express server and switch off logging when in production, as shown in the following code snippet:

if (process.env['NODE_ENV'] !== "production")
 app.use(express.logger({ immediate: true, format: 'dev' }));

Get Advanced Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.