Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core trace logging on Azure with Application Insights

I have an ASP.NET Core web project deployed to Azure with Application Insights configured. Insights is receiving data fine for requests etc. but I am unable to get it to display my logs.

I am using the vanilla Microsoft.Extensions.Logging framework and have a test error being logged on a controller action as

logger.LogError("Test application insights message");

In my Startup.cs Configure method I have set

loggerFactory.AddAzureWebAppDiagnostics();

... and can successfully see the error message appear in Azure logs streaming:

2017-04-14 11:06:00.313 +00:00 [Error] Test application insights message

However, I also want this message to appear in Application Insights trace but it is nowhere to be found. I think I need to configure the ILoggerFactory but not sure how and can't find any docs on the subject.

Thanks in advance for your help

like image 885
Alasdair Thomson Avatar asked Apr 14 '17 11:04

Alasdair Thomson


People also ask

How do I integrate Azure application insights?

How do I use Application Insights? Application Insights is enabled through either Auto-Instrumentation (agent) or by adding the Application Insights SDK to your application code. Many languages are supported and the applications could be on Azure, on-premises, or hosted by another cloud.


1 Answers

case anybody else trying to resolve this, I got the results I wanted with the following:

loggerFactory.AddApplicationInsights(app.ApplicationServices);
like image 79
Alasdair Thomson Avatar answered Oct 18 '22 21:10

Alasdair Thomson