- Add
Microsoft.ApplicationInsights.AspNetCore
to the list of packages.
- Add the application insights logger to Program.cs
Host.CreateDefaultBuilder(args)
.ConfigureLogging(l =>
{
l.AddApplicationInsights();
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
- Configure logging in appSettings.json
{
"Logging": {
"ApplicationInsights": {
"LogLevel": {
"<<Category>>": "Debug"
}
}
},
"AllowedHosts": "*"
}
- Go to Application Insights and click on Logs (Analytics)
- Data will take a bit to show up.
- Use a query like the following to query for events in a given category.
traces
| where customDimensions.CategoryName contains "Microsoft.AspNetCore.Components"