nodejs console输出到文件

2021-08-06 04:56

阅读:646

标签:ram   lin   create   rip   err   att   param   javascrip   java   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‘) } console.error = function() { logFile.write(util.format.apply(null, arguments) + ‘\n‘) process.stderr.write(util.format.apply(null, arguments) + ‘\n‘) }nodejs console输出到文件标签:ram   lin   create   rip   err   att   param   javascrip   java   原文地址:https://www.cnblogs.com/youxin/p/14889043.html


评论


亲,登录后才可以留言!