var fs = require(“fs”); // create a write stream (in append mode) var accessLogStream = fs.createWriteStream('/data/logs/node/access.log’, {flags: 'a’}) // setup the logger app.use(morgan('combined’, {stream: accessLogStream}))
上面代码的结果是所有日志内容都存储在access.log里,不像nginx生成的log自动分割