How to Log Full Stack Trace with Winston 3?

For winston version 3.2.0+, following will add stacktrace to log output:

import { createLogger, format, transports } from 'winston';

const { combine, timestamp, prettyPrint, colorize, errors,  } = format;


const logger = createLogger({
  format: combine(
    errors({ stack: true }), // <-- use errors format
    colorize(),
    timestamp(),
    prettyPrint()
  ),
  transports: [new transports.Console()],
});  

Ref: https://github.com/winstonjs/winston/issues/1338#issuecomment-482784056

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)