Skip to content

Instantly share code, notes, and snippets.

@javiercn
Created August 20, 2019 16:51
Show Gist options
  • Save javiercn/efec4a3ade7e4143c8404d3587729c21 to your computer and use it in GitHub Desktop.
Save javiercn/efec4a3ade7e4143c8404d3587729c21 to your computer and use it in GitHub Desktop.
Cheatsheets - A list of varied cheatsheets to accomplish common ASP.NET Core tasks
  • 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" 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment