从AWS lambda日志中删除元数据

发布于 2025-01-22 08:35:11 字数 405 浏览 2 评论 0原文

我有一个带有许多lambdas的无服务器应用程序。我正在使用 datadog lambda Extensive 将日志推向datadog。

我的lambda日志非常混乱,因为它们具有与每个日志关联的时间戳,请求ID和日志级别(以及Datadog Trace ID)。有没有一种方法可以从日志中删除此元数据,并且只需记录的内容(理想情况下也保留日志级别?)。为了参考,我们使用标准console.logconsole.warn等...方法。

I have a serverless application with many Lambdas. I'm using the Datadog Lambda Extension to push logs to Datadog.

My Lambda logs are very cluttered since they have the timestamp, requestID, and log level associated with each log (along with the Datadog trace id). Is there a way to remove this metadata from logs, and just have the content that is logged (and ideally preserve the log level too?). For reference, we are using the standard console.log, console.warn, etc... methods.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

伴梦长久 2025-01-29 08:35:11

可以通过修改控制台对象来解决该问题,并使用新的控制台对象进行记录

const { Console } = require('console');


const logger = new Console({
   stdout: process.stdout,
   stderr: process.stderr,
});

logger.log("This is a clean log message");

The issue can be fixed by modifying the console Object, and use the new console object for logging

const { Console } = require('console');


const logger = new Console({
   stdout: process.stdout,
   stderr: process.stderr,
});

logger.log("This is a clean log message");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文