English 中文(简体)
ExpressJS - Debugging
  • 时间:2024-09-17

ExpressJS - Debugging


Previous Page Next Page  

Express uses the Debug module to internally log information about route matching, middleware functions, apppcation 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 pttle overwhelming. You can also restrict the DEBUG variable to specific area to be logged. For example, if you wish to restrict the logger to apppcation and router, you can use the following code.

DEBUG = express:apppcation,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