Lightweight JSON Lines (JSONL) logger with pluggable formatters for VictoriaLogs, Google Cloud Logging, and more.
The jsonl-logger package is a lightweight, structured logger that outputs JSON Lines — one JSON object per line. It works across Bun, Node.js, Deno, and browsers with zero dependencies, making it a portable choice for any JavaScript runtime.
The core idea is simple: structured logs are easier to parse, query, and analyze than plain text. Each log entry is a valid JSON object with a timestamp, severity level, message, and arbitrary metadata. The logger supports standard severity levels (debug, info, warn, error) and can optionally intercept console.* calls to capture third-party output.
import { logger } from 'jsonl-logger'
logger.info('Server started', { port: 3000 })
logger.log('Neutral message', { note: 'no level icon' })
logger.error('Request failed', { path: '/api' }, new Error('timeout'))
What makes it flexible is the pluggable formatter system. Built-in formatters transform log output to match the expected schema of Google Cloud Logging (GCL), VictoriaLogs, or any custom format you define. There is also OpenTelemetry trace context support for correlating logs with distributed traces.
The logger is designed to stay out of your way — no configuration is required for basic usage, but every aspect can be customized when needed.