admin管理员组文章数量:1122846
I have an Azure function
- I created application insight resource when creating Function App
- Azure function has registered Insights telemetry by default
Environment variable in Azure Portal (default)
Program.cs (default)
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
Function Logs in Azure Portal console
Function Logs in Logs workspace
The issue and question is, why I see the following logs in Azure Portal Log Console
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
but not in Logs workspace
?
Any idea?
Update 1:
I verified that the application insight is connected to function app
Log levels are set to information: host.json
{
"version": "2.0",
"logging": {
"LogLevel": {
"Default": "Information"
},
"applicationInsights": {
"LogLevel": {
"Default": "Information"
},
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request;Exception"
},
"enableLiveMetricsFilters": true
}
}
}
Update 2:
_logger.LogInformation("[Http Triggered Function] Information.");
_logger.LogWarning("[Http Triggered Function] Warning.");
_logger.LogError("[Http Triggered Function] Error.");
Warning and errors are logged correctly
Update 3
Seems like host.json configuration is not taking into account at all. If I want to log only errors
{
"version": "2.0",
"logging": {
"LogLevel": {
"Default": "Error",
"Function": "Error",
"Function.Function1": "Error",
"Function.ChangeTrackingFunction": "Error"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Warning are still being logged into console and into Logs workspace.
I have an Azure function
- I created application insight resource when creating Function App
- Azure function has registered Insights telemetry by default
Environment variable in Azure Portal (default)
Program.cs (default)
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();
})
.Build();
Function Logs in Azure Portal console
Function Logs in Logs workspace
The issue and question is, why I see the following logs in Azure Portal Log Console
_logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
but not in Logs workspace
?
Any idea?
Update 1:
I verified that the application insight is connected to function app
Log levels are set to information: host.json
{
"version": "2.0",
"logging": {
"LogLevel": {
"Default": "Information"
},
"applicationInsights": {
"LogLevel": {
"Default": "Information"
},
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request;Exception"
},
"enableLiveMetricsFilters": true
}
}
}
Update 2:
_logger.LogInformation("[Http Triggered Function] Information.");
_logger.LogWarning("[Http Triggered Function] Warning.");
_logger.LogError("[Http Triggered Function] Error.");
Warning and errors are logged correctly
Update 3
Seems like host.json configuration is not taking into account at all. If I want to log only errors
{
"version": "2.0",
"logging": {
"LogLevel": {
"Default": "Error",
"Function": "Error",
"Function.Function1": "Error",
"Function.ChangeTrackingFunction": "Error"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Warning are still being logged into console and into Logs workspace.
Share Improve this question edited Dec 11, 2024 at 0:10 Muflix asked Nov 21, 2024 at 17:24 MuflixMuflix 6,75819 gold badges92 silver badges170 bronze badges 2 |1 Answer
Reset to default 1In the Logs workspace of your Azure Function, if custom logs are absent, check these most likely culprits: There are a few possible explanations for this:
Logging Configuration: Make sure that logging is configured in the Azure Function App that you are using. Use the Azure portal settings to verify that Application Insights has been set.
Log Levels: Ensure that your function code invokes logs at the right log levels. If Node.js is your choice, for example, console.log() should be used at the Information level or higher. In Python, make use of print() statements as needed.
Diagnostic Settings: Find out if you have turned on diagnostic settings for your Function App. In the absence of these settings, logs are unlikely to be transmitted to the Log Analytics workspace. They can indeed be activated in Azure portal under the “Monitoring” tab of your Function App.
Application Insights Integration: You need to confirm that your Function App has been integrated with Application Insights. Lack of or an erroneous instrumentation key or connection string means the log may not be transmitted to Application Insights and hence not show in the Logs workspace.
本文标签: Why I don39t see Azure Function Information logs in Logs workspaceStack Overflow
版权声明:本文标题:Why I don't see Azure Function Information logs in Logs workspace - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308522a1933692.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
host.json
seems to be not applied at all. I would like to log all logs but the information logs are not available in the application insight logs, but printed only into the console. – Muflix Commented Nov 29, 2024 at 15:54