Connecting the ASP.NET Core logger to Azure Application Insights

In Chapter 7, Troubleshooting and Debugging, you added the Application Insights provider to ASP.NET Logger Factory.  The Application Insights provider searches for an instrumentation key in your application's configuration, and if it finds it, it uses it to send log messages (called Trace messages in Application Insights) to your cloud resource.

You can find the instrumentation key of your Application Insights when you navigate to the Application Instance resource in the Azure portal and click on the Properties menu item:

You can add the instrumentation key directly to your appsettings.json file, which is useful for writing logs to Azure even from the local machine, but it's advisable not to store the instrumentation key in your source control, so be careful.

{
...
"ApplicationInsights": {
"InstrumentationKey": "XX7b8ff5-YY88-ZZaf-XXb1-YY47d2d958bb"
}
...
}

Another option is to take advantage of the way Azure App Service manages Application settings and how ASP.NET Core configuration works.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.253.198