您能否描述一下您是如何启用 ApplicationInsights 来捕获 ILogger 的?如果您使用的是 SDK 的最新 beta 版本,则无需显式操作即可捕获 ILogger 跟踪。但它只会捕获警告或以上级别的日志。
按照此文档配置应用程序洞察力以捕获不同的日志级别。
https://docs.microsoft.com/en-us/azure/azure-monitor/app/ilogger#control-logging-level
如果您未使用最新的 SDK,则需要根据上述文档明确启用应用程序洞察力以捕获 ilogger 日志。在这里,您还需要配置日志记录级别,以便捕获 LogInformation。
.ConfigureLogging(
builder =>
{
builder.AddApplicationInsights("ikey");
builder.AddFilter<Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider>("", LogLevel.Information); // this will capture Info level traces and above.
}