we are using winston logger to log events to nodejs fs
, i want to write every event into new line using winston, is it possible with to achieve that task using winston library or any other approach that works with nodejs.
ctrl.js
var winston = require('winston');
var consumer = new ConsumerGroup(options, topics);
console.log("Consumer topics:", getConsumerTopics(consumer).toString());
logger = new (winston.Logger)({
level: null,
transports: [
// new (winston.transports.Console)(),
new (winston.transports.File)({
filename: './logs/st/server.log',
maxsize: 1024 * 1024 * 20,//15728640 is 15 MB
timestamp: false,
json: false,
formatter: function (options) {
return options.message;
}
})
]
});
function startConsumer(consumer) {
consumer.on('message', function (message) {
logger.log('info', message.value);
//callback(message.value);
io.io().emit('StConsumer', message.value);
});
consumer.on('error', function (err) {
console.log('error', err);
});
};
startConsumer(consumer);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…