There are following ways to log in Node.js:
console.log: The original method of logging is console.log which is a function that writes a message to log on the debugging console, but you have little control over it where things log from outside the code.
Debug module: The advantage of using debug is that a lot of packages use it. You can turn it on to urge additional information on what’s happening in web middleware like Express and Koa when your back-end gets an internet request. The good frameworks will offer you how to attach logging middleware, but you would possibly not get all the small print sent there too.
Middleware Middleware is simply something you’ll put into the request pipeline. Ways to setup logging middleware:
const app = express()
const loggingMiddleware = require(
const router = express.Router()
const routeLoggingMiddleware = require(
Winston Package: Winston includes storage options,different log levels & queries and a profiler.