A library for writing MongoDB logv2 messages, commonly used in MongoDB tools and drivers. Current stable version is 2.5.13, released as part of the mongodb-js/devtools-shared monorepo. It provides a structured log writer with support for log rotation, retention, gzip compression, and dynamic log level management. The library ships TypeScript type definitions and is compatible with MongoDB's logv2 format, making it suitable for applications that need to produce logs parsable by MongoDB tooling. Release cadence follows the monorepo's schedule, with updates tied to peer dependency changes (bson v4, v5, v6, or v7).
npm install mongodb-log-writerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a log manager, configure log rotation with gzip, and write a logv2 message with a custom ID and metadata.
Use dynamic import() in CJS environments: import('mongodb-log-writer').then(m => ...).Always use integer literals: mongoLogId(1001) not mongoLogId(someVariable).
Use 'retentionDays' instead.
Always call 'writer.flush()' or use 'await writer.flush()' before shutting down.
Install a compatible BSON version: npm install bson@^4.6.3 or ^5 etc.
Change to dynamic import: const { MongoLogManager } = await import('mongodb-log-writer');Use named import: import { mongoLogId } from 'mongodb-log-writer';Ensure it's imported as a value: import { MongoLogManager } from 'mongodb-log-writer';Install the package: npm install mongodb-log-writer. Ensure tsconfig.json has 'moduleResolution': 'node' or 'bundler', and 'esModuleInterop': true.