Winston: how to rotate logs

前端 未结 5 1477
傲寒
傲寒 2020-12-08 04:13

How can I rotate logs when using Winston to handle logging for node.js. That is, how can I create a new file for each day the app runs?

    var logger = new          


        
5条回答
  •  独厮守ぢ
    2020-12-08 04:58

    winston author and maintainer here.

    Logging to a new file everyday is currently an open feature request: https://github.com/flatiron/winston/issues/10. Would love to see someone implement it.

    That said, there are other options:

    1. The File transport accepts a maxsize option which will rotate the logfile when it exceeds a certain size in bytes.

    2. There is also an open pull-request with a new transport I haven't had a chance to really dig into "fileRotate", which it seems does this kind of date-based rotation: https://github.com/flatiron/winston/pull/120/files

提交回复
热议问题