I am new to Winston, when there is an error on the code it gets logged to the console but not to the log file. Infos get logged to another file correctly but errors don't.
Here's my logger.js file:
const winston = require('winston')
let logger
module.exports.init = () => {
logger = winston.createLogger({
level: 'info',
format: winston.format.simple(),
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: './logs/error.log', level: 'error' }),
new winston.transports.File({ filename: './logs/info.log' })
]
})
process.on('uncaughtException', ex => {
logger.error(ex.message)
process.exit(1)
})
process.on('unhandledRejection', ex => {
logger.error(ex.message)
process.exit(1)
})
}
module.exports.use = () => logger
I've used the code here, but it won't work. Any help would be really appreciated.