通过“ Addlambdalogger”将所有内容添加为[信息]
我最近在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论