title: Invalid transport, must be an object with a log method winston mongodb logging
body: <p>I want to store my error logs in mongoDB collection. I am using winston &amp; winston -mongoDB.</p>
  
  <p>Getting the error:</p>
  
  <blockquote>
    <p>throw new Error('Invalid transport, must be an object with a log
    method.'); Error: Invalid transport, must be an object with a log
    method.</p>
  </blockquote>
  
  <p>Here is the code in logger file.
      Here is my code:
      import appRoot from 'app-root-path';
      import {
          createLogger,
          transports,
          format,
      } from 'winston';</p>
  
  <pre><code>import * as winston from 'winston';
  
  
  require('winston-mongodb');
  
  
  const options = {
      fileInfo: {
          level: 'info',
          filename: `${appRoot}/logs/info.log`,
          handleExceptions: true,
          json: true,
          maxsize: 5242880, // 5MB
          maxFiles: 5,
          colorize: false,
          timestamp: true,
      },
      mongoDB: {
          db: 'mongodb://127.0.0.1:27017/test',
          collection: 'log',
          level: 'info',
          storeHost: true,
          capped: true,
      },
  };
  
  winston.add(winston.transports.MongoDB, options.mongoDB);
  
  
  const logger = createLogger({
      format: format.combine(
          format.timestamp({
              format: 'YYYY-MM-DD HH:mm:ss',
          }),
          format.json()
      ),
      transports: [
          new transports.File(options.fileInfo)
      ],
  });
  
  logger.stream = {
      write: (message, encoding) =&gt; {
          logger.info(message);
      },
  };
  
  export default logger;
  </code></pre>
  
  <p>Versions:</p>
  
  <pre><code> "mongoose": "^5.2.6",
      "morgan": "^1.9.0",
      "winston": "^3.0.0",
      "winston-mongodb": "^4.0.3",
      mongodb@3.1.1
  </code></pre>