.netloggingappinsights

Microsoft Logging not found in App Insights Logs


I have a .net 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?


Solution

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

    logging.AddApplicationInsights();