我正在使用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": "*"
},
ConfigureServices:
services.AddHostedService<Worker>();
services.AddApplicationInsightsTelemetryWorkerService();
检测密钥在Azure中设置。 我遵循了以下指示:https://docs.microsoft.com/en-us/azure/azure-monitor/app/worker-service#net-core-30-worker-service-application
答案 0 :(得分:0)
我添加了此问题的帖子:
根据op提供的代码/配置,两者都是正确的。我也确认在我这边可以。
所以我想这个问题可能是由于应用程序洞察获取服务器的延迟所致。