小编Mic*_*ski的帖子

使用 Amazon Linux 2 在 Elastic Beanstalk 上输出 JSON 日志

我们正在尝试将我们的 Java 应用程序从当前的 Elastic Beanstalk JDK 8 平台迁移到在 Amazon Linux 2 上运行 Corretto 11 的新平台。该应用程序运行良好,但处理日志的方式发生了变化。Web 进程的输出现在存储在其中/var/log/web.stdout.log,每一行都以时间戳和进程名称为前缀,即:

May 20 17:00:00 ip-10-48-41-129 web: {"timestamp":"2020-05-20T17:00:00.035Z","message":"...","logger":"...","thread":"MessageBroker-2","level":"INFO"}
Run Code Online (Sandbox Code Playgroud)

我们怎样才能摆脱前缀?这些日志被流式传输到 CloudWatch,我们将它们以 JSON 格式输出到标准输出,以便我们稍后可以使用 Logs Insights 查询它们。但是使用前缀,Insights 不会“看到”JSON,只是将整行视为文本 blob。

我在 AWS 上找不到任何相关文档。几乎所有 Elastic Beanstalk 的文档都提到了 Amazon Linux 的第一个版本。

amazon-web-services elastic-beanstalk amazon-linux-2

5
推荐指数
2
解决办法
963
查看次数