I'm trying to log stacktrace along with error message using Winston. My logger is configured with custom formatter:
this.errorLogger = winston.createLogger({
levels: this.levels,
level: 'error',
transports: [
new WinstonFileRotator({
filename: '%DATE%.log',
dirname: 'logs/error',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
handleExceptions: true,
json: false,
format: winston.format.combine(
winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
}),
winston.format.printf(info => {
return '[${info.timestamp}] -> ${info.message}';
}),
),
})
]
});
I log the error along with stacktrace:
this.errorLogger.error('My message', ex.Stack);
In my log I have a line:
[2018-09-03 23:41:14] -> My message
How can I access in my custom formatter the metadata that I passed to error function along with the message?