Open Algram opened 7 years ago
I know this is a super old question, but you can create your own formatter
const timeStampFormatter = format((info, opts = {}) => {
if (opts.format) {
info['@timestamp'] = typeof opts.format === 'function'
? opts.format()
: fecha.format(new Date(), opts.format);
}
if (!info.timestamp) {
info['@timestamp'] = new Date().toISOString();
}
if (opts.alias) {
info[opts.alias] = info.timestamp;
}
return info;
});
then use it when creating your logger
const logger = createLogger({
format: format.combine(
timeStampFormatter({
format: 'YYYY-MM-DD HH:mm:ss'
}),
// other formatters
),
// other options
});
Hello,
I would like to change the field name from
timestamp
to@timestamp
in the JSON-File. How can I do that with Winston?Thank you for your help!