I recently stumbled upon winston logging and started to use in one of my nodejs applications.
My configuration is below:
// Setup winston logging
var loggerSettings = {
level: logConfig.dev.level,
//format: combine(label({label: 'authServer'}), timestamp(), myFormat),
levels: logLevels.levels,
transports: [ new winston.transports.Console({
colorize:true,
format: winston.format.simple(),
json: false
})
] // by default console log will always be present.
};
winston.addColors(logLevels);
logger = winston.createLogger(loggerSettings);
module.exports = logger;
And.. logLevels is defined as below...
const logLevels = {
levels: {
fatal: 0,
error: 1,
warning: 2,
info: 3,
debug: 4,
trace: 5
},
colors: {
fatal: 'red',
error: 'orange',
warning: 'yellow',
info: 'green',
debug: 'blue',
trace: 'gray'
}
};
Even though I declared the colors option (colorize:true), I am unable to see any colored output on the console. I have also required the colors modules in the beginning of this file.
Thanks for any help, in fixing this issue.