Log4j Fluentd读取多行码头日志

Log4j Fluentd读取多行码头日志,log4j,jetty,config,fluentd,Log4j,Jetty,Config,Fluentd,我试着读一个jetty日志的多行,对于一个源,现在有人知道怎么做吗 <source> type tail format multiline format_firstline /^\[/ format1 /^\[[^ ]* (?<time>[^\]]*)\] *(?<level>[^ ]*) $/ path /mnt/current/log/jettylog4j.log pos_file /mnt/current/log/fluentd.jettylog4j.p

我试着读一个jetty日志的多行,对于一个源,现在有人知道怎么做吗

<source>
type tail
format multiline
format_firstline /^\[/
format1 /^\[[^ ]* (?<time>[^\]]*)\] *(?<level>[^ ]*) $/
path /mnt/current/log/jettylog4j.log
pos_file /mnt/current/log/fluentd.jettylog4j.pos
read_from_head true
tag jettylog
refresh_interval 30
</source>

型尾
格式化多行
第一行的格式/^\[/
格式1/^\[^]*(?[^\]]*)\]*(?[^]*)$/
路径/mnt/current/log/jettylog4j.log
pos_文件/mnt/current/log/fluentd.jettylog4j.pos
从你的头上读出来是真的
标签jettylog
刷新间隔30

有了这个,我无法将所有行都包含在消息中。

看来您正在使用log4j进行日志记录

其输出格式和语法由其log4j配置控制

您可能希望将fluentd工作与log4j配置同步,甚至可能在log4j配置端进行一些小的调整,以使您在fluentd中的生活更轻松

注意,log4j甚至可以配置为以xml或json格式输出,或者直接输出到fluentd数据库中,这至少使解析步骤更简单


提示:如果您决定这样做,您会想知道您使用的是log4j 1.x还是2.x(因为文档不同)

在我的情况下,我无法更改格式,因为这是遗留代码的一部分。我找到了一个适合我的模式。我把它放在这里以防对某人有用

<source>
type tail
format multiline
format_firstline /^\[/
format1 /^\[[^ ]* (?<time>[^\]]*)\] *(?<level>[^ ]*) (?<message>[^\n]*(\n^[^\[].*|$))/
path /mnt/current/log/jettylog4j.log
pos_file /mnt/current/log/fluentd.jettylog4j.pos
read_from_head true
tag jettylog
refresh_interval 30
</source>

型尾
格式化多行
第一行的格式/^\[/
格式1/^\[^]*(?[^\]]*)\]*(?[^]*)(?[^\n]*(\n^[^\[].\124;$)/
路径/mnt/current/log/jettylog4j.log
pos_文件/mnt/current/log/fluentd.jettylog4j.pos
从你的头上读出来是真的
标签jettylog
刷新间隔30