gpt4 book ai didi

Azure Functions - 注入(inject)的 ILogger 日志未显示

转载 作者:行者123 更新时间:2023-12-04 01:31:09 26 4
gpt4 key购买 nike

我正在使用FunctionsStartup在 Azure Functions 项目中设置 IoC 绑定(bind)。但是,从注入(inject)的 ILogger<T> 创建的任何日志当我在 Azure 中运行它时,没有出现。

我创建了一个非常精简的版本,其中包含一个全新的示例项目来演示这一点...

https://github.com/dracan/AzureFunctionsLoggingIssue

这个的输出是...

2020-04-03T20:20:35  Welcome, you are now connected to log-streaming service. The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds). 
2020-04-03T20:20:54.643 [Information] Executing 'TestQueueTriggerFunction' (Reason='New queue message detected on 'myqueue'.', Id=2f13c4c7-8a35-4614-a768-1c3fecea8c31)
2020-04-03T20:20:54.654 [Information] Start of function (this log works)
2020-04-03T20:20:54.655 [Information] End of function (this log also works)
2020-04-03T20:20:54.655 [Information] Executed 'TestQueueTriggerFunction' (Succeeded, Id=2f13c4c7-8a35-4614-a768-1c3fecea8c31)

请注意 MyClass.DoSomething() 中的日志条目“此日志未出现!”没有出现。

最佳答案

看起来这是一个已知问题。引用微软在Github上的回复:

This is another subtlety about how that console/debug log works in the portal. It only displays log messages if it knows they come from this function -- which means they match the category Function.{FunctionName}.User. The ILogger we pass in uses this category automatically but anything you log with an external logger will not use this. We do this so that you don't get flooded with background messages in this view -- and unfortunately it filters out your own custom logger as well.

I've got an issue tracking this with one potential workaround: Azure/azure-functions-host#4689 (comment).

关于Azure Functions - 注入(inject)的 ILogger<T> 日志未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61019859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com