我创建了一个功能应用程序,并为其集成了应用程序见解。
-
然后,我在本地创建了一个Timmer触发器函数应用程序,并通过添加插入键连接到应用程序洞察。
-
我能够运行功能应用程序并在我的洞察力中跟踪日志,但是,我得到了所有默认的&函数只记录在同一个跟踪表中。因此,为了克服这一点,我已经采取了日志级别,请检查以下文件。
host.json:
{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Information",
"Host.Results": "Information",
"Function": "Information",
"Host.Aggregator": "Trace",
"Function.Function1.User": "Trace",
"Function.Function1.System": "Debug"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Dependency;Request;PageView",
"maxTelemetryItemsPerSecond": 20,
"httpAutoCollectionOptions": {
"enableHttpTriggerExtendedInfoCollection": true,
"enableW3CDistributedTracing": false,
"enableResponseHeaderInjection": false
}
}
}
},
"functionTimeout": "02:00:00",
"extensions": {
"queues": {
"maxPollingInterval": "00:00:01",
"visibilityTimeout": "00:00:15",
"batchSize": 1,
"newBatchThreshold": 2,
"maxDequeueCount": 2
}
}
}
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */1 * * * *")] TimerInfo timer, ILogger logger)
{
logger.LogInformation("This is an information-level log message.");
logger.LogWarning("This is a warning-level log message.");
logger.LogError("This is an error-level log message.");
logger.LogTrace("This is a trace-level log message.");
logger.LogDebug("This is a debug-level log message.");
logger.LogCritical("This is a critical-level log message.");
}
}
-
通过与host.json文件的通信,我能够成功地运行。
查询:
traces
| where severityLevel in (0, 1, 2, 3, 4, 5)
| order by timestamp desc
结果: