ExpressJS - Debugging


Advertisements


Express uses the Debug module to internally log information about route matching, middleware functions, application mode, etc.

To see all internal logs used in Express, set the DEBUG environment variable to Express:* when starting the app −

DEBUG = express:* node index.js

The following output will be displayed.

Debug log

These logs are very helpful when a component of your app is not functioning right. This verbose output might be a little overwhelming. You can also restrict the DEBUG variable to specific area to be logged. For example, if you wish to restrict the logger to application and router, you can use the following code.

DEBUG = express:application,express:router node index.js

Debug is turned off by default and is automatically turned on in production environment. Debug can also be extended to meet your needs, you can read more about it at its npm page.



Advertisements
E-Books Store