通过“ Addlambdalogger”将所有内容添加为[信息]

发布于 2025-01-24 05:13:39 字数 600 浏览 0 评论 0原文

我最近在AWS lambda功能中添加了日志记录,并在检查日志时发现了一些奇怪的事情。

通过记录器记录的所有内容都显示为[信息],即使呼叫专门为警告错误

这是我设置记录器的地方:

serviceCollection.AddLogging(logging =>
{
    logging.AddLambdaLogger();
    logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Information);
});

它被作为ilogger作为构造函数参数的实例被注入,

ILogger<MyClass> logger

因此,当我调用类似的内容时

_logger.LogWarning($"Oh no");

,我希望它会记录为> [警告],但在日志中显示为[信息]

I recently added logging to a AWS Lambda function and noticed something weird when I checked the logs.

Everything being logged via the logger was showing as [Information] even if the call was specifically to log as a Warning or Error.

Here is where I set up the logger:

serviceCollection.AddLogging(logging =>
{
    logging.AddLambdaLogger();
    logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Information);
});

and it gets injected as an instance of ILogger as a constructor parameter like this:

ILogger<MyClass> logger

So when I call something like

_logger.LogWarning(
quot;Oh no");

I would expect it to log that as [Warning] but in the logs it shows as [Information]

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文