Azure Function v4未登录到部署到Azure的Application Insights,而是在本地登录



我有一个简单的Azure函数v4,在C#上实现。打个简单的电话:

_logger.LogTrace(
new LogTraceParameter
{
Message = "Message to be logged",
FunctionName = context.FunctionName,
SeverityLevel = SeverityLevel.Information,
Category = Category.Request,
SubCategory = SubCategory.Incoming
});

该功能在本地运行良好,并登录到App Insights。但在部署到门户时不起作用。Host.json:

{
"version": "2.0",
"logging": {
"logLevel": {
"default": "Trace"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}

我也检查了Instrumetal钥匙。试图删除";excludedTypes":"请求";,或添加";Function.FunctionName":"Trace";到host.json文件。这并没有起到任何作用。哪里可能有错误?

你检查过应用洞察的azure门户上的配置吗?

您能更改&quot_记录器。LogTrace";至"_记录器。LogError";,以排除问题是否与严重性有关?对于常规的asp.net核心,默认情况下只收集Warning或更高版本,不确定这是否会影响您。。。https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core?tabs=netcore6#ilogger-记录

最新更新