My Blog

My WordPress Blog

My Blog

My WordPress Blog

Handling Exceptions

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; });
Handling Exceptions

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top