I want to add timestamp to logs. What is the best way to achieve this?
Sometimes default timestamp format can be not convenient for you. You can override it with your implementation.
Instead of
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({'timestamp':true})
]
});
you can write
var winston = require('winston');
var logger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
'timestamp': function() {
return ;
}
})
]
});
See https://github.com/winstonjs/winston#custom-log-format for the details