Logging in express js to a output file?

后端 未结 7 1154
醉话见心
醉话见心 2020-12-12 23:26

What is best way to log my express js webserver? The inbuilt express.logger() just displays logs on screen. Can I also log them into a file in /log folder? Also the current

7条回答
  •  情书的邮戳
    2020-12-13 00:16

    You should try winston

    var logger = new (winston.Logger)({
      transports: [
        new (winston.transports.Console)(),
        new (winston.transports.File)({ filename: 'somefile.log' })
      ]
    });
    

提交回复
热议问题