Fluentd 在单行中格式化 Java 异常日志

sou*_*n.c 5 fluentd google-cloud-stackdriver

我在 GCP 中部署了一个 java 应用程序。使用 fluentd 将该日志文件指向 Stackdriver 日志记录。

Java exception log在单独的行中格式化。因此 Stackdriver 日志记录无法将其捕获为 error/warning 。

我需要在一行中格式化我的 java 应用程序异常跟踪。 需要区分信息、错误、警告。

我流畅的配置:

<source>
  type tail
  format none
  path /home/app/*-local-app-output.log
  pos_file /var/lib/google-fluentd/pos/local-app.pos
  read_from_head true
  tag local-app
</source>
Run Code Online (Sandbox Code Playgroud)

也试过

  format multiline
  format_firstline /\d{4}-\d{1,2}-\d{1,2}/
  format1 /^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}) \[(?<thread>.*)\] (?<level>[^\s]+)(?<message>.*)/
  time_format %b %d %H:%M:%S
Run Code Online (Sandbox Code Playgroud)

当前显示输出: 在此处输入图片说明

而在 Kubernetes 引擎中部署相同的应用程序,它有单独的日志类别字段: info , warn , error , critical 。

谁可以帮我这个事 ?