Hey everyone i need help setting up my Winston logging config. I am migrating an existing project with 300 + console.logs to winston and now the values of the logs are not printed anymore. I researched online and only found hacky solutions that didn't work for me. Any help is appreciated.
This is my logger config
// logger config
const winston = require('winston')
const { combine, timestamp, colorize, align, printf } = winston.format
const logger = winston.createLogger({
// level: process.env.LOG_LEVEL || 'info',
level: 'silly',
format: combine(
colorize({ all: true }),
timestamp({
format: 'YYYY-MM-DD hh:mm:ss',
}),
align(),
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
), transports: [new winston.transports.Console()],
})
module.exports = logger
This is how the console log was before:
console.log('active jobs : ',
(await queue.getActive()).length)
Output:
active jobs : 12
This is how it is now:
logger.info(
'active jobs : ',
(await queue.getActive()).length
)
Output:
[2022-05-23 03:57:29] info: active jobs :
I would appreciate if there is a possibility without changing the console.logs since they are so many.