Join us Sept 17 at .local NYC! Use code WEB50 to save 50% on tickets. Learn more >
MongoDB Event
Docs Menu
Docs Home
/ / /
Node.js Driver
/

Logging

Important

The driver doesn't use the logger in versions 4.0 and later. Attempting to use prior logger settings in this version won't print anything in the log.

Instead, see our monitoring guides:

  • Command Monitoring

  • Cluster Monitoring

  • Connection Pool Monitoring

We are developing a new logging framework. In the meantime, you can output monitor events by using the following snippet:

const uri = "mongodb+srv://<user>:<password>@<cluster-url>?writeConcern=majority";
const client = new MongoClient(uri, { monitorCommands:true });
client.on('commandStarted', (event) => console.debug(event));
client.on('commandSucceeded', (event) => console.debug(event));
client.on('commandFailed', (event) => console.debug(event));

Back

Connection Pool

On this page