Node Logging Libraries

Last updated Sep 06, 2021nodelibslists

Getting started with JavaScript and logging your first line using console.log is quick, but when you take your code to production, there’s much more you should consider about logging:

  • Output formats (string, json, files, streams, etc.)
  • Different log levels for different log categories
  • Multiple configurable writable streams
  • Interactive and regular modes
  • String interpolation support
  • Configurable log rolling based on file size or date

Following are notable libraries to write logs in Node applications.

  • winston - Designed to be a simple and universal logging library with support for multiple transports. A transport is essentially a storage device for your logs.
  • bunyan - Simple and fast JSON logging library for node.js services, extensible streams system for controlling where log records go.
  • morgan - HTTP request logger middleware for Node.
  • debug - Tiny JavaScript debugging utility modelled after Node.js core’s debugging technique. Works in Node.js and web browsers
  • signale - Can be used for logging purposes, status reporting, as well as for handling the output rendering process of other node modules and applications.
  • log4js - A conversion of the log4js framework to work with node. I started out just stripping out the browser-specific code and tidying up some of the javascript to work better in node
  • loglevel - Minimal lightweight logging for JavaScript, adding reliable log level methods to wrap any available console.log methods
  • npmlog - The logger util that npm uses, very basic, supports custom levels and colored output, all logs written to stderr by default.