鉴于此 appsettings.json
{
"ApplicationInsights": {
"InstrumentationKey": "foobar",
"LogLevel": {
"Default": "Debug"
}
},
"Logging": {
"LogLevel": {
"Default": "Debug"
}
},
"AllowedHosts": "*"
}
而这来自startup.cs
public void ConfigureServices(IServiceCollection services)
{
var appSettingsSection = Configuration.GetSection("TD");
var appSettings = new AppSettings();
new ConfigureFromConfigurationOptions<AppSettings>(appSettingsSection).Configure(appSettings);
services.Configure<AppSettings>(appSettingsSection);
services.AddApplicationInsightsTelemetry();
services.AddTransient<IMyService, MyService>();
services.AddControllersWithViews();
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp";
});
}
为什么在我的 AI 输出中仍然只看到严重、错误和警告?
例如来自控制器的任意日志
public async Task<IActionResult> MyAction(string foobar)
{
Logger.LogDebug($"Ilogger debug {foobar}");
Logger.LogInformation($"Ilogger info {foobar}");
Logger.LogWarning($"Ilogger warning {foobar}");
Logger.LogError($"Ilogger error {foobar}");
Logger.LogCritical($"Ilogger critical {foobar}");
}
根据这里的微软文档
当您通过以下任一方法打开常规 Application Insights 监视时,ApplicationInsightsLoggerProvider 在 Microsoft.ApplicationInsights.AspNet SDK 版本 2.7.1(及更高版本)中默认启用:
- 通过调用 UseApplicationInsights 扩展方法 onIWebHostBuilder(现已过时)
- 通过调用 IServiceCollection 上的 AddApplicationInsightsTelemetry 扩展方法
所以我对为什么没有输出调试/信息跟踪有点迷茫。
appsettings.development.json 中没有覆盖或日志记录设置。
我正在使用 AppInsights SDK 2.13.1。
ASP.NET 核心 3.1。