Enabling debug logs
debug
is a popular library, used by many notable frameworks, including the Express.js and Koa.js web frameworks and the Mocha test framework. debug
is a small JavaScript debugging utility based on the debugging technique used in Node.js core.
In the recipe, we'll discover how to enable debug logs on an Express.js application.
Getting ready
- Let's create an Express.js web application that we can enable debug logs on. We'll first need to create a new directory and initialize our project:
$ mkdir express-debug-app $ cd express-debug-app $ npm init --yes $ npm install express
- Now, we'll create a single file named
server.js
:$ touch server.js
- Add the following code to
server.js
:const express = require("express"); const app = express(); app.get("/", (req, res) => res.send("Hello World!")); app.listen(3000, () => { console.log("Server listening on port 3000"); });
Now...