I'm trying to use Winston to create logs, but it is not writing in the file.
I have the following file in controllers/myControler/myFile.js
const path = require('path');
const winston = require('winston');
const filename = path.join(__dirname, 'testLog.log');
const logger = winston.createLogger({
transports: [
new winston.transports.Console({ filename, level: 'error' })
]
});
exports.test = async (req, res, next) => {
logger.log({
level: 'error',
message: 'Test'
});
}
I have the file testLog.log in the root of my project.
When I run the application, I can see in the terminal:
{"level":"error","message":"Test"}
However, the testLog.log file still empty.
Thanks
question from:
https://stackoverflow.com/questions/65837945/nodejs-winston-not-writing-in-the-log-file 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…