在 .NET 8 功能的 Application Insights 中未获取信息或跟踪日志

问题描述 投票:0回答:1

我已经使用 .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
        }
    }
}

还有人遇到类似的情况吗?

azure-functions azure-application-insights
1个回答
0
投票

我在这个堆栈溢出问题和答案中找到了答案。

感谢@Vivek

Azure Function 记录到 App Insights 的日志记录不会低于警告级别

© www.soinside.com 2019 - 2024. All rights reserved.