我使用的是Microsoft.Extensions.Hosting.BackgroundService.在ExecuteAsync方法中,我启动了遥测操作:
using (_telemetryClient.StartOperation<RequestTelemetry>("someOperationName"))
{ [service implementation goes here] }在服务实现中,我使用_logger.LogInformation。我还在我的服务实现中调用不同类的其他方法,这些方法也记录信息。
这些条目不会显示在Azure中。
是否有办法在Azure应用程序洞察(Performance ->操作选项卡)中自动显示所有调用的方法的日志条目?
应用程序设置:
"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
发布于 2020-01-21 09:43:13
我添加了这篇文章来结束这个问题:
根据op提供的代码/配置,它们都是正确的。我也在我身边确认过,它是有效的。
所以我猜这个问题可能是由于应用程序洞察接收服务器的延迟造成的。
https://stackoverflow.com/questions/59732136
复制相似问题