How to flush winston logs?

后端 未结 5 711
抹茶落季
抹茶落季 2020-12-18 19:19

I want to flush the winston logger before process.exit.

process.on(\'uncaughtException\', function(err){
    logger.error(\'Fatal uncau         


        
5条回答
  •  萌比男神i
    2020-12-18 19:35

    Winston actually allows you to pass in a callback which is executed when all transports have been logged:

    process.on('uncaughtException', function(err) {
        logger.log('error', 'Fatal uncaught exception crashed cluster', err, function(err, level, msg, meta) {
            process.exit(1);
        });
    });
    

    Docs: https://github.com/flatiron/winston#events-and-callbacks-in-winston

提交回复
热议问题