Board logo

标题: [文本处理] 批处理抓取log文件内容,看到关键字放入新文件 [打印本页]

作者: kjajk6366    时间: 2017-1-18 10:27     标题: 批处理抓取log文件内容,看到关键字放入新文件

想用BATCH去实时读取一个LOG文件,LOG文件内容如下:

2017-01-13 05:56:46.751 INFO  [CoagentReportReceiver:26:receive][pool-39-thread-
1] - 接收到状态报告入状态报告队列,totalLength = 63 commandID = 7 sequenceId = 22
4132 commandStatus = 32 destmobile = xxxxxxxxxxx Stat = 2 ErrorCode = IC:00006 S
rcSequenceId = 9128701091547334700 PkNumber = 1
2017-01-13 05:56:46.751 INFO  [CoagentReportReceiver:26:receive][pool-39-thread-
1] - 接收到状态报告入状态报告队列,totalLength = 63 commandID = 7 sequenceId = 22
3890 commandStatus = 32 destmobile = xxxxxxxxxxx Stat = 2 ErrorCode = IC:00006 S
rcSequenceId = 9128701091547294556 PkNumber = 1
2017-01-13 05:56:46.751 INFO  [CoagentReportReceiver:26:receive][pool-39-thread-
1] - 接收到状态报告入状态报告队列,totalLength = 63 commandID = 7 sequenceId = 22
4154 commandStatus = 32 destmobile = xxxxxxxxxxx Stat = 2 ErrorCode = IC:00006 S
rcSequenceId = 9128701091547354769 PkNumber = 4

我想实现:1、LOG文件是某个系统的日志文件,会持续地扩大,所以这个BATCH也需要一直保持运行;2、如发现某条记录中有ErrorCode =IC:00006,需要把整条记录放入一个新的txt文件,叫error.log;3、记录和记录之间使用回车间隔的。

想问下各位大神能否实现?或者提供下思路,谢谢!
作者: zz100001    时间: 2017-1-18 12:29

tail -f XXX | grep YYY >> ZZZ
作者: GNU    时间: 2017-1-18 13:01

先下载 tail.exe 和 grep.exe 再执行2楼的命令
http://bbs.bathome.net/s/tool/index.html




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2