I use Winston for logging:
var winston = require('winston');
var logger = new(winston.Logger)({
transports: [
new(winston.transports.Console)(),
new(winston.transports.File)({filename: '/var/log/logF.log'})
]
});
and I write to this log:
logger.log("File: " + path + " was found");
For some reason, the file /var/log/logF.log
isn't updated, and also the standard output isn't shown the log.
How do I use it so the log will be written in '/var/log/logF.log'?
You haven't specified a log "level", and "log" is unfortunately not a default level. Try:
logger.log("info", "File: was found");
// or
logger.info("File: was found");
After trying and made severals tests with severals advanced logging mechanisms (incl. winston, bunyan, log4js), it appears that loggers are not able to write into file if you do a clean exit process.exit(0)
.
Removing clean exit solve the problem for me.
I had this issue this evening. However, I realized the file location wasn't being resolved. I'm not sure if this will solve your issue.
filename: path.resolve(__dirname, "add_your_relative_path/error.log")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With