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