【发布时间】:2012-07-17 09:14:04
【问题描述】:
我的 Tomcat 日志是以这种格式构建的:
[<DATE>] [<COMPONENT>] ERROR_TYPE <ERROR_NAME> - <Rest of line>
其中ERROR_TYPE 是a log4j value,例如DEBUG 或ERROR。
例如,
[18/Jul/2012:08:53:39 +0000] [component1] ERROR ConnectionTimeOut - ...
[18/Jul/2012:09:54:32 +0000] [component2] DEBUG IPNotFound - ...
[18/Jul/2012:09:54:32 +0000] [component1] TRACE Connected - ...
[18/Jul/2012:08:53:39 +0000] [component1] ERROR ConnectionTimeOut - ...
我想创建一个从元组(ERROR_TYPE, ERROR_NAME) 到出现次数的映射,例如
ERROR ConnectionTimeOut 2
DEBUG IPNotFound 1
TRACE Connected 1
我该如何匹配:
_anything_ (ERROR|DEBUG|TRACE|WARN|FATAL_spaces_ _another_word_)_anything_
在 AWK 中,只返回括号中的部分?
【问题讨论】: