c# - Application Insights Telemetry Client - 如何在 Azure Application Insights 中显示日志条目
问题描述
我正在使用 Microsoft.Extensions.Hosting.BackgroundService。在 ExecuteAsync 方法中,我开始遥测操作:
using (_telemetryClient.StartOperation<RequestTelemetry>("someOperationName"))
{ [service implementation goes here] }
在服务实现中,我使用 _logger.LogInformation。而且我还在我的服务实现中调用了不同类的其他方法,这些方法也记录了信息。
这些条目不会显示在 Azure 中。
有没有办法在 Azure Application Insights(性能 -> 操作选项卡)中自动显示所有调用方法的日志条目?
应用设置:
"Logging": {
"ApplicationInsights": {
"LogLevel": {
"Default": "Information"
}
},
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"AllowedHosts": "*"
},
配置服务:
services.AddHostedService<Worker>();
services.AddApplicationInsightsTelemetryWorkerService();
检测密钥在 Azure 中设置。我按照以下说明操作:https ://docs.microsoft.com/en-us/azure/azure-monitor/app/worker-service#net-core-30-worker-service-application
解决方案
我添加了关闭此问题的帖子:
根据op提供的代码/配置,它们都是正确的。我也在我身边证实,它有效。
所以我猜这个问题可能是由于应用程序洞察摄取服务器的延迟。
推荐阅读
- tsql - SSMS - 自动完成参数(智能感知)
- r - R:堆叠条形图的ggplot,绘图和自动调整
- javascript - Javascript:如何在新窗口中安全地打开用户提供的 URL
- java - 在 Hibernate Query 中为一个特定属性生成错误
- angularjs - 当我从数据库中获取轴值时,Highchart 不工作
- javascript - 禁用输入范围的键盘使用
- python - 使用 Seaborn 分割小提琴图和调色板
- node.js - 检查 Firebase 用户是否存在且未引发错误
- swift - 使用 Swift 4 用非素数向下三角求和
- ios - 如何根据文本字段上选定的日期选择器打印年龄?