How to flush winston logs?

后端 未结 5 727
抹茶落季
抹茶落季 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条回答
  •  悲&欢浪女
    2020-12-18 19:43

    Unfortuantely, Winston will sometimes call the logging callback before the transport has had a chance to flush, so the accepted answer can still lead to un-saved log messages (especially on the first turn of the event loop). A better solution is implemented in the winston-log-and-exit package / patch.

提交回复
热议问题