log4js-node ports the log4js-style logging model to Node.js with appenders, layouts, and per-category levels. It stays silent by default so libraries can depend on it safely.
Overview
log4js-node is a Node.js logging package modeled after the broader log4js ecosystem, adapted for server-side JavaScript rather than browsers. It is not meant to mirror Java log4j behavior line for line, but provides familiar concepts such as categories, levels, and appenders.
Built-in capabilities include colored console output to stdout or stderr, rolling file appenders by size or date, Connect and Express middleware logging, pattern-based message layouts, and different verbosity per category. Optional appenders extend output to SMTP, GELF, Loggly, Logstash UDP, logFaces, TCP centralization, InfluxDB, and similar targets.
By default the framework logs nothing until the default category level is raised from OFF, which lets library code reference log4js without forcing log noise on consumers. Configuration can be loaded from JSON files, and clustering guides cover multi-process Node deployments.
Library maintainers can integrate via log4js-api to avoid hard dependencies for end users. TypeScript typings and migration notes cover major version shifts.
Key features
- Console, file, and rolling file appenders
- Per-category log levels
- Connect and Express request logging
- Configurable layouts and patterns
- Optional remote and metrics appenders
- Cluster-aware logging guidance
Use cases
- Structured logging in Node.js servers
- Centralized logs across multiple Node processes
- Library-friendly optional logging hooks