The code below logs all requests to two files, one of which is JSON formatted. This has the side effect of logging each request to the console twice. Why is that? I am sure I'm using Winston incorrectly, any feedback would be appreciated.
var winston = require('winston');
winston.loggers.add('main_nojson', {
file: {
filename: '/home/stu/logs/winston_txt.log',
json: false
}
});
winston.loggers.add('main_json', {
file: {
filename: '/home/stu/logs/winston_json.log',
json: true
}
});
var winlog1 = winston.loggers.get('main_nojson');
var winlog2 = winston.loggers.get('main_json');
var winstonStream = {
write: function(message, encoding){
winlog1.info(message);
winlog2.info(message);
}
};
app.use(express.logger({stream:winstonStream, format: ':remote-addr - [:date] ":method :url HTTP/:http-version" :status :res[content-length] ":referrer" ":user-agent" :response-time' }));