node console.log输出到文件
2021-10-15 本文已影响0人
周周周__
var fs = require('fs')
var util = require('util')
var logPath = 'upgrade.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')
}