0
私たちはkafkaバスからイベントをレンダリングし、winston loggerを使用してファイルシステムに書き込んでいます。そのため、特定の機能を強化するために、ファイルからイベントを検索する必要があります。ログファイル。だから私の質問は、私たちがファイルにログオンするときにwinston
を使ってIDの何らかの種類を生成することが可能かどうかです。winston loggingを使用してイベントIDを作成するにはどうすればよいですか?
winstonServer.js
var Consumer = {
start: function() {
var logger = new(winston.Logger)({
level: null,
transports: [
new(winston.transports.Console)(),
new(winston.transports.File)({
filename: './logs/dit/server.log',
maxsize: 1024 * 1024 * 15, // 15MB
timestamp: false,
maxFiles: 10,
json: false,
formatter: function(options) {
return options.message;
}
})
]
});
function startConsumer(consumer) {
consumer.on('message', function(message) {
logger.log('info', message.value);
io.io().emit('ditConsumer', message.value);
});
consumer.on('error', function(err) {
console.log('error', err);
});
};
startConsumer(consumer);
}
}
のserver.log
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
testid Lorem test Ipsum is simply dummy text text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took 43fd41a7-d1fb-4c19-9de6-19170aee171f a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
すべてのログで同じIDを生成しています.2番目の問題は、IDがコンソールの 'logger.log'から印刷していますidsを 'server.log'ファイル – hussain
Yeop、私は一度修正して家に到着します - それはlogIdでなければなりません:uuid.v4()はメソッド呼び出しのパラメータの右にあります。私は、転送APIをチェックし、それがファイルに記録する場所を明記するように修正します。 – BlackStork
さて、私は新しいIDを参照していますが、まだIDがログファイルのIDであることを目的としたログファイルには書かれていません – hussain