I am getting below error and I also know that it is throwing because the server.log file does not exist.
But what I want to know is how to handle this error programmatically like we do for unCaughtException e.g
process.on('unCaughtException', function(err){
logger.error(err1)
})
Below is the error, I am getting:
events.js:141
throw er; // Unhandled 'error' event
^
Error: ENOTDIR: not a directory, stat '../logs/server.log'
at Error (native)
Below is the actual code ..that is throwing this error.
module.exports = new winston.Logger({
transports: [
new winston.transports.File({
level: 'info',
filename: '../logs/server.log',
json: false,
maxsize: 5242880, //5MB
maxFiles: 2,
colorize: false
}),
new winston.transports.Console({
level: 'debug',
json: false,
colorize: true
})
],
exitOnError: false
});