目前,我有一个项目正在使用带有 .net core 3.1 的 Azure Function,我想知道如何跟踪每个调用的方法,例如:
[FunctionName("Count")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "Count")] HttpRequest req,
ILogger log)
{
int cnt = selectCount("Select * from A");
}
public static int selectCount(string str)
{
return 2;
}
它将记录到 Azure Log Analytics 工作区,而无需Log.Information("Function:Count Start");
和Log.Information("selectCount Start");
日志消息示例如下
_________________________________________________ | 时间生成 | 留言 | |2020/11/17 09:00:00.000 | 功能:计数开始 | |2020/11/17 09:00:00.002 | 选择计数开始 | |2020/11/17 09:00:00.003 | 选择计数结束 | |2020/11/17 09:00:00.001 | 功能:计数结束 | _________________________________________________