- 论坛徽章:
- 0
|
我现在的需求是,每分钟取一次日志的信息出来导入临时文件,日志是实时写入的。
日志格式如下:(展示的格式大概如下)
[2014-01-09 21:55:52,068] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
<?xml version="1.0" encoding="UTF-8"?>
<message>
<head>
<field name="chanl_sub_no"><![CDATA[0702]]></field>
</head>
<body>
<field name="ORG"><![CDATA[169]]></field>
</body>
</message>
[2014-01-09 21:55:52,133] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
<?xml version="1.0" encoding="gb2312"?>
<message>
<head>
<field pin="false" name="version"><![CDATA[100]]></field>
</head>
<body>
<field-list name="RECORD">
<field-list name="0">
<field pin="false" name="AVAIL-CREDIT"><![CDATA[4800]]></field>
</field-list>
</field-list>
</body>
</message>
[2014-01-09 21:55:53,073] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
<?xml version="1.0" encoding="UTF-8"?>
<message>
<head>
<field name="chanl_sub_no"><![CDATA[0702]]></field>
</head>
<body>
<field name="ORG"><![CDATA[169]]></field>
</body>
</message>
[2014-01-09 21:55:53,116] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
<?xml version="1.0" encoding="gb2312"?>
<message>
<head>
<field pin="false" name="version"><![CDATA[100]]></field>
</head>
<body>
<field-list name="RECORD">
<field-list name="0">
<field pin="false" name="ORG"><![CDATA[169]]></field>
</field-list>
</field-list>
</body>
</message>
[2014-01-09 21:55:53,244] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
<?xml version="1.0" encoding="gb2312"?>
<message>
<message-header>
<field name="msg_serv_acct_no"><![CDATA[gj]]></field>
</message-header>
<message-body>
<field name="msg_aaa_no"><![CDATA[xxxxxxxxx]]></field>
</message-body>
</message>
[2014-01-09 21:55:53,254] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
<?xml version="1.0" encoding="UTF-8"?>
<message>
<head>
<field name="chanl_sub_no"><![CDATA[0702]]></field>
</head>
<body>
<field name="ORG"><![CDATA[169]]></field>
</body>
</message>
[2014-01-09 21:55:53,268] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
<?xml version="1.0" encoding="gb2312"?>
<message>
<message-header>
<field pin="false" name="msg_version_id"><![CDATA[100]]></field>
</message-header>
<message-body/>
</message>
比如我现在要取21:55:52到21:55:53之间所有的日志信息怎么做?
我的是这样取得:
awk -vFS="[][,]+" '$2>="2014-01-09 21:55:52" && $2<="2014-01-09 21:55:53"' 1.txt
但是得出的结果只有包含时间的哪些行:
[root@test1 ~]# awk -vFS="[][,]+" '$2>="2014-01-09 21:55:52" && $2<="2014-01-09 21:55:53"' 1.txt
[2014-01-09 21:55:52,068] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:52,133] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
[2014-01-09 21:55:53,073] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:53,116] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
[2014-01-09 21:55:53,244] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:53,254] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:53,268] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
[2014-01-09 21:55:53,297] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
[2014-01-09 21:55:53,513] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:53,556] [ INFO] [app.utils.Utils.logInfo:397] - 发送交易报文:
[2014-01-09 21:55:53,562] [ INFO] [app.utils.Utils.logInfo:397] - 返回报文:
我想得到一分钟内所有的报文信息输出到临时文件,后续在处理这个临时文件。谢谢
|
|