Winston log to file not working

Or Smith picture Or Smith · Jan 8, 2015 · Viewed 10.7k times · Source

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'?

Answer

laggingreflex picture laggingreflex · Jan 8, 2015

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");