when logger is being exported to a new file it does not create a log, I have two files
1] abc.js
let winston = require('winston');require('winston-logrotate');
var logger = new winston.Logger({
level: 'info',
transports: [
new (winston.transports.File)({ filename: 'somefile.log' })
]
});
module.exports = logger;
2] app.js
const logger = require('./abc');
logger.info("is it working"); // not change is made in the log file after this command
console.log(logger); // this is working
I had this issue this evening. However, I realized the file location wasn't being resolved. Remember to import path :)
filename: path.resolve(__dirname, "add_your_relative_path/error.log")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.