Search code examples
mongodbmeteorwinston

Winston logging to MongoDB collection in Meteor


I've configured Winston logger package in Meteor and I want to insert logs into MongoDB Collection so it can be visible on my yogibean:admin page after deployment to digitalocean.

As a part of configuring logging module I'm doing that:

logger.add(Winston.transports.MongoDB, {
  db: 'myDataBaseName',
  collection: 'logs',
  host: '???', // or dbUri
  username: '???',
  password: '???',
  name: 'mongo.mainLogs',
});

My main question is:

What should I use as a host or dbUri to be able to deploy this? Is there any environment variable with host or dbUri to MongoDB?


Solution

  • As @BraveKenny suggested propper configuration is:

    logger.add(Winston.transports.MongoDB, {
      db: process.env.MONGO_URL,
      collection: 'logs',
      name: 'mongo.mainLogs',
    });
    

    I don't need to use username and password until I will configure database with some.