Answer the question
In order to leave comments, you need to log in
How to use Winston to specify the path of the executable file in the console?
How to get the path of the current executable where message was assigned. It is currently displaying itself.
let logger = new (winston.Logger)({
transports: [
new winston.transports.Console({ level: config.get("LOGGER_LEVEL"),timestamp: function () {
return moment().format('HH:mm:ss');
},formatter: function(options) {
let path = module.filename.split('/').slice(-2).join('/');
return options.timestamp() + ' - ' + options.level+': '+options.message +
"\n\r" + path;
},colorize: true}),
new winston.transports.File({ filename: './log/server.log', level: 'verbose',timestamp: function () {
return moment().format('YYYY-MM-DD HH:mm:ss')
} })
]
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question