【发布时间】:2021-01-18 04:22:20
【问题描述】:
注意:如果有人对如何做到这一点有一点想法,请写一个答案:)
如何启用一项功能,以便在调试时在 azure 函数控制台窗口中显示的堆栈跟踪中捕获每个异常的文件名和行号。 或者更好的是,在调试 azure 函数时如何在 Visual Studio 中触发调试断点?
我已经尝试启用调试信息=完整,在项目设置->构建->高级->调试信息=完整,但这没有任何效果。
这里有一些代码会生成一个索引越界异常来说明问题:
List<string> test = new List<string>();
Console.WriteLine(test[0]);
当我在调试模式下运行 azure 函数并遇到异常时,这是控制台窗口生成的输出:
[2020-10-02T13:01:38.289] Executed 'Function1' (Failed, Id=180bf39f-1b60-401e-80a4-2073de926e9e, Duration=340ms)
[2020-10-02T13:01:38.290] System.Private.CoreLib: Exception while executing function: Function1. System.Private.CoreLib: One or more errors occurred. (Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')). System.Private.CoreLib: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index').
这是项目中的 Host.json 文件:
【问题讨论】:
-
我猜你需要使用applicationInsight
-
@DervişKayımbaşıoğlu 我会在将代码部署到 azure 时使用它,但我需要能够在本地开发并在调试时看到此信息:)
-
您有用于日志记录的启动配置吗?你能把它添加到问题中吗?
-
@DervişKayımbaşıoğlu 我已将其添加到问题的底部。
标签: c# .net-core azure-functions stack-trace