【发布时间】:2021-03-25 00:53:38
【问题描述】:
我在一个日志文件中有两种类型的日志(不同格式):
- 第一个日志格式:
2019-09-01 18:58:05,898 INFO Thread: qtp1497973286-16 - com.xyz.soap
<with additional stuff>
<more stuff>
<even morestuff>
timestamp:2019-09-01 18:58:05,898, level:INFO, thread:qtp1497973286-16, message:com.xyz.soap ... <to the end of last line>
- 第二种日志格式:
2021-03-23 23:47:38.111:ERROR::main: Logging initialized @5687ms to org.eclipse.jetty.util.log.StdErrLog
WARNING: An illegal reflective access operation has occurred
More lines here
timestamp:2021-03-23 23:47:38.111, level:ERROR, thread:main, message:Logging ... <to the end of last line>
我正在尝试找到具有统一输出捕获组的正则表达式模式:timestamp, thread, level, message.
例如,这种模式“几乎”适用于第一组:
(?<timestamp>[^ ]* [^ ]*) (?<level>[^\s][A-Z]+)[\s]+(?<thread>\s.*) (?<message>[\s\S]*)$
我正在使用神奇的 regex101 工具:https://regex101.com/r/AW9VKp/1
我需要找到两种日志格式生成相同组的模式。
【问题讨论】:
标签: regex regex-group fluentd fluent-bit