首页 > 编程知识 正文

log4net异步写入日志,大容量日志恢复模式

时间:2023-05-05 13:04:18 阅读:10167 作者:1744

首先,logger使用解读重定向的iproxy和wda的日志iproxywda 前言 开发与解读的 stf代码基于Github mrx1203的代码 wda代码基于Github mrx1203的代码 nohup ./悲伤毛巾/stf local知道可以将stf日志重定向到nohup.out,以便在线调试时查看日志。 但是,如果日志过多,则存在难以查找iproxy和wda的日志的问题(iproxy、wda的日志过多,涂画面的类型)。 所以单独保存iproxy和wda的日志需要提上日程。 logger使用解读stf使用lib/util/logger.js 在外部使用Logger,首先浏览Logger.js文件var logger=require (' ./././util/logger ) /相对路径,根据实际文件位置进行确定,然后创建logger 功能日志(tag ) this.tag=tagthis.names ) 1:'DBG )、2:'vrb )、3:'INF )、4: '文艺之象)、43: this.styles={1:'grey ',2: 'cyan ',3: 'green ',4: 'magenta ',53: ' yellow 73360 ' red ' } tthisxxxxx

x ' )方法打印log时,内部

源代码log.prototype.info=function ({ this._ write ) this._entry ) logger.level.info, arguments )//arguments之前_Entry的第一个参数是日志级别INFO}/*_entry函数,它调用entry类以合并数据*/log.prototype._ entry=args )返回新日志。优先级//日志级别,this.tag,process.pid,this.local identifier|| logger.global identifier/util.format.aaagier args日志信息(}//bean构造函数log.entry=function(timestamp,priority,tag,pid,identifier, message (this.timestamp=timestamp this.priority=priority this.tag this.PID=PID this.identifier=identifier 打印log.prototype._ write=function (entry ) console.error ) this._format(entry )//nohup时,终端上打印的日志会自动显示为no hhop 不重要的logger.emit('entry ',entry ) ) iproxy和wda日志iproxy //重定向到在当前工作目录下创建iproxy_log目录if (! fs.existssync(./Iproxy_log/' ) (fs.mkdirsync )./Iproxy_log/' ) varIproxy_log_path=)./path 每个设备都可以使用由设备id命名的唯一log文件const out=fs.opensync (I proxy _ log _ path,' a ' ); //打开附加模式文件consterr=fs.opensync (I proxy _ log _ path,' a ' ); pro=newsubppocess(Iproxy )、[localPort,remotePort,'-u ',options.serial]、{ detached: true, stdio3360} ERR(//stdout和stderr重定向) subprocess选项中安装了detached和stdio,说明为Nodejs中文网http://nodejs.cn/API /

3358 nodejs.cn/API/child _ process.html # child _ process _ options _ stdio。

wda if (! fs.existssync(./WDA_log/) ) fs.mkdirsync )./WDA_log/' ) }varWDA_log_path='./WDA_log/在此,与iproxy不同,通过fs的createWriteStream进行间歇性的数据流*/constfsstream=fs.createwritestream ({ flags : ' a ', 编码3360 ' utf8 ' } (fs stream.on )、() fd )={ log.info (wdafsstreamopen ) } () fd (err ) ) log.info (ww 因此,不能使用上述iproxy方法将stdout完全重定向到文件(父进程无法接收子进程的标准输出)。

wdapro.on(stream-line ),line={fsstream.write(line(n ) }if ) line.indexof ) serverurlhere-'!=-1 ) log.info(wda启动成功) ) wda.launchapp ) com.apple.preferences ) (wda.initSession ) (wda.emit ) ) starences

wdapro.on('stream-line ',line={fsstream.write ) line'n ' )。 接下来,与空闲业务无关的代码在github上被开源了。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。