Winston can handle uncaught exceptions and unhandled rejections.
const logger = winston.createLogger({
level: 'info',
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'combined.log' })
],
exceptionHandlers: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'exceptions.log' })
]
});
process.on('unhandledRejection', (ex) => {
throw ex;
});
Leave a Reply