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.
- signale - Can be used for logging purposes, status reporting, as well as for handling the output rendering process of other node modules and applications.
- npmlog - The logger util that npm uses, very basic, supports custom levels and colored output, all logs written to stderr by default.