我已经使用 .NET8 在 VS 2022 中创建了一个函数。在本地它工作正常但信息日志没有显示在应用程序见解中。我可以看到警告日志和错误日志。
我认为我的代码可能是问题所在。我也尝试使用示例函数,它也没有在 Application Insights 中显示任何信息或跟踪日志,但在本地显示日志。
using System;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace Schedule
{
public class Time
{
private readonly ILogger _logger;
public Time(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<Time>();
}
[Function("Time")]
public void Run([TimerTrigger("0 */50 * * * *")] TimerInfo myTimer)
{
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
if (myTimer.ScheduleStatus is not null)
{
_logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
_logger.LogTrace("testing trace logs in Application Insights");
}
}
}
}
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}
还有人遇到类似的情况吗?