Replace console.log in a Node.js app with structured JSON logs searchable by level, time range, or any custom field.
Stream logs to multiple destinations at once, file, stdout, and a monitoring service, each at a different severity level.
Use child loggers to automatically tag every log line from a request or session with shared context fields like a request ID.
Pipe raw JSON log output through the bunyan CLI to get colorized, human-readable output during local development.
Bunyan is a logging library for Node.js applications. Its central idea is that server logs should be structured data rather than free-form text, so every log entry it produces is a single line of JSON. Each line includes fields like the application name, process ID, hostname, timestamp, severity level, and the message you asked it to log. Because the output is machine-readable JSON, it is easy to search and filter with other tools. The library has a small API. You create a logger by calling bunyan.createLogger with a name and optional settings, then call methods named after severity levels: trace, debug, info, warn, error, and fatal. Each call writes a JSON line to wherever you have configured the logger to write. You can also pass extra fields alongside the message, and those fields get folded into the JSON record. Error objects are handled specially so their stack traces are captured in a structured way. Bunyan comes with a command-line tool, also called bunyan, that reads the raw JSON log output and displays it in a human-friendly, colorized format. The CLI can also filter records by level, time range, or any custom field, so you can search through logs without relying on grep over plain text. The streams system controls where log output goes. You can write to a file, to stdout, to a rotating file (where old log files are moved aside automatically), or to any custom destination. Loggers can fan out to multiple streams at different severity levels, for example writing everything to a file but only warnings and above to a monitoring service. Child loggers let you create a specialized copy of an existing logger that inherits its settings but adds extra fields automatically to every record it writes. The full README is longer than what was shown.
← trentm on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.