Pino transport for inserting structured JSON logs into MongoDB. Current stable version is 5.0.0, released in 2024. This package is part of the Pino logger ecosystem and supports both modern Pino transports and legacy CLI usage. It allows users to pipe log streams directly into MongoDB collections, with options for custom parsing and authentication. Compared to other MongoDB log transports, it integrates seamlessly with Pino's pipeline and can handle high-throughput logging. The library is actively maintained with frequent releases.
npm install pino-mongodbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up Pino logger with MongoDB transport and logs a sample message. Also shows alternative CLI usage.
Use parseLine option to transform log objects: opts.parseLine = (str) => { const obj = JSON.parse(str); // wrap problematic keys }Use pino.transport({ target: 'pino-mongodb', options: { ... } })Avoid using reserved keys or use parseLine to rename them.
Wrap such keys under a nested property, e.g., { query: { $and: [...] } }. Use parseLine option to transform logs.Upgrade to pino@7 or later, or use legacy require pattern.
Install the package: npm install pino-mongodb. If using ESM, use import syntax.