Skip to content

Instantly share code, notes, and snippets.

@wafe
Created March 8, 2012 10:16
Show Gist options
  • Save wafe/2000145 to your computer and use it in GitHub Desktop.
Save wafe/2000145 to your computer and use it in GitHub Desktop.
node.js uncaughtException logging using winston
var winston = require('winston'); // https://github.com/flatiron/winston
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename : 'winston.log', timestamp: true, /*maxsize: 2000, maxFiles: 5*/ })
]
});
process.on('uncaughtException', function (err) {
logger.error('uncaughtException', { message : err.message, stack : err.stack }); // logging with MetaData
process.exit(1); // exit with failure
});
@crobinson42
Copy link

Awesome gist! Thanks for posting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment