nodejs console.log写入到文件
代码
var fs = require('fs')
var util = require('util')
var logPath = 'console.log'
var logFile = fs.createWriteStream(logPath, { flags: 'a' })
console.log = function () {
logFile.write(util.format.apply(null, arguments) + '\n')
process.stdout.write(util.format.apply(null, arguments) + '\n')
}