Reputation: 14375
In my node application i'm using winston module to store my application logs.I have tried to store the logs in different level and also in different files.In this situation i'm getting error as "Error: Transport already attached: file".
My Code
var winston=require('winston');
winston.add(winston.transports.File, { filename: './logfile.log',level:'error' });
winston.add(winston.transports.File, { filename: './logfile1.log',level:'warn' });
winston.add(winston.transports.File, { filename: './logfile2.log',level:'debug'});
winston.log('error', 'Error message!');//this should go to logfile.log
winston.log('warn', 'Warning message!');//this should go to logfile1.log
winston.log('debug', 'Debug message!');//this should go to logfile2.log
Upvotes: 0
Views: 985
Reputation: 181
winston.add(winston.transports.File, { name:'log.error', filename: './logfile.log',level:'error' }); winston.add(winston.transports.File, { name:'log.warn', filename: './logfile1.log',level:'warn' }); winston.add(winston.transports.File, { name:'log.debug', filename: './logfile2.log',level:'debug'});
do it like that!
Upvotes: 4
Reputation: 48
The winston just support one file transfer in a instance ,you can make more instance to handle the difference level log.
Upvotes: 0