最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - Microsoft Logging not found in App Insights Logs - Stack Overflow

programmeradmin0浏览0评论

I have a core app and configured app insights like this

Program.cs:

return WebHost.CreateDefaultBuilder(args)
   .UseApplicationInsights()
   .ConfigureLogging(logging =>
   {
       logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Trace);
   })
   .UseStartup<Startup>();

Startup:

services.AddApplicationInsightsTelemetry();
services.AddLogging();

appsettings.json:

"ApplicationInsights": {
    "InstrumentationKey": "my-key"
}

App insights is turned on for the app service and receives data, but apparently not for logging like

_logger?.LogInformation("important info!");

The logs are empty if I query with

traces
| sort by timestamp desc 

Is missing anything obvious?

I have a core app and configured app insights like this

Program.cs:

return WebHost.CreateDefaultBuilder(args)
   .UseApplicationInsights()
   .ConfigureLogging(logging =>
   {
       logging.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Trace);
   })
   .UseStartup<Startup>();

Startup:

services.AddApplicationInsightsTelemetry();
services.AddLogging();

appsettings.json:

"ApplicationInsights": {
    "InstrumentationKey": "my-key"
}

App insights is turned on for the app service and receives data, but apparently not for logging like

_logger?.LogInformation("important info!");

The logs are empty if I query with

traces
| sort by timestamp desc 

Is missing anything obvious?

Share Improve this question edited Nov 21, 2024 at 8:23 AGuyCalledGerald asked Nov 20, 2024 at 9:47 AGuyCalledGeraldAGuyCalledGerald 8,17018 gold badges77 silver badges123 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

in Program.cs, there was missing a line in ConfigureLogging:

logging.AddApplicationInsights();
发布评论

评论列表(0)

  1. 暂无评论