Logging in express js to a output file?

后端 未结 7 1153
醉话见心
醉话见心 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:04

    you should try cluster http://learnboost.github.com/cluster/ for Node. Use express to build the app, while the cluster take over the rest tasks including logging.

    1. app.use(express.logger()); // in your express apps, ex: app.js
    2. cluster.use(cluster.logger('logs')) ; // in your cluster server, ex: server.js

提交回复
热议问题