【发布时间】:2020-09-01 18:09:46
【问题描述】:
重现步骤:
在VS中新建一个V2函数应用 选择HTTP触发器,粘贴以下代码:
log.LogTrace("This is a trace log");
log.LogDebug("This is a debug log");
log.LogInformation("This is an information log");
log.LogWarning("This is a warning log");
log.LogError("This is an error log");
log.LogCritical("This is a critical log");
return new OkResult();
进入host.json,配置如下:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": false
},
"fileLoggingMode": "always",
"logLevel": {
"default": "Trace",
"Host.Results": "Error",
"Function": "Trace",
"Host.Aggregator": "Trace"
}
}
}
}
运行主机,触发HTTP功能 预期结果 - 跟踪消息应出现在应用程序洞察中
实际结果: 在应用洞察中查询
union traces
| union exceptions
|union requests
| where timestamp > ago(30d)
| where operation_Id == 'be439155fd015344badd3839da2652a8'
| where customDimensions['InvocationId'] == '6057a32f-0f59-4193-8845-a5f9d972169f'
| order by timestamp asc
| project timestamp, message = iff(message != '', message, iff(innermostMessage != '', innermostMessage, customDimensions.['prop__{OriginalFormat}'])), logLevel = customDimensions.['LogLevel']
timestamp [UTC] message
8/31/2020, 4:00:58.764 PM Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=6057a32f-0f59-4193-8845-a5f9d972169f) Information
8/31/2020, 4:00:58.764 PM Information Logged
8/31/2020, 4:00:58.953 PM error Logged
8/31/2020, 4:00:58.954 PM Warning Logged
8/31/2020, 4:00:58.954 PM Executed 'Function1' (Succeeded, Id=6057a32f-0f59-4193-8845-a5f9d972169f, Duration=190ms)
【问题讨论】:
标签: azure asp.net-core azure-functions azure-application-insights serverless-framework