bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
797 stars 187 forks source link

How to listen on ''loggin" event ? #180

Open krazylearner opened 6 years ago

krazylearner commented 6 years ago

Hey,

In default winston logger we can listen on 'logging' event with something like this

var logger = new (winston.Logger)({
    transports: [
      new (winston.transports.Console)({ level: 'info' }),
      new (winston.transports.File)({ filename: 'app.log' })
    ]
  });

 logger.on('logging', function (transport, level, msg, meta) {
    console.log(msg);
  });

Is there anyway we can do the same for expressWinston?

Thanks

dmichelin commented 6 years ago

Supply express-winston with a winston-instance that has the callback

crellison commented 5 years ago

@krazylearner did the answer provided by @dmichelin work for you? You should be able to print to stdout by specifying a transporter. Does this solution not work for you?