Reputation: 817
I am working on my first project on Application Insights and facing some issues.
Tech Stack
Project Type - Azure Durable Functions
.NetStandard 2.0
Visual Studio 2017
Problem
In the HTTPStart method, I add a custom log message using ILogger (and TraceWriter).
Sample Code
log.LogInformation("******* Test Message********");
When I am running application on my local, host file is as:
{
"version": "2.0",
"logger": {
"categoryFilter": {
"categoryLevels": {
"Host.Triggers.DurableTask": "Information"
}
}
}
}
With this background, I am trying to figure out the following issues:
The problem is, I can see generic statements (out of the box) being logged but the custom log with the help of ILogger / TraceWriter are not being shown.
Upvotes: 1
Views: 3671
Reputation: 29940
Update:
In you function app -> Monitor blade, If anything is ok, you should see application insights logs there. like the screenshot below:
The following is my host.json by default:
{
"version": "2.0"
}
The following is my application settings in portal:
and after I publish it to azure, and I can see the custom logs writing by ILogger is shown in azure portal -> application insights(it may take a few minutes):
Just for the 2nd issue, For console app or similar project, the "Application Insights Search" function is not available.
I install Microsoft.ApplicationInsights 2.8.1, and add the following two custom logs:
[FunctionName("Function1_Hello")]
public static string SayHello([ActivityTrigger] string name, ILogger log)
{
log.LogInformation($"Saying hello to {name}.");
log.LogInformation("xxxxxx ssssssss wwwwwwww");
return $"Hello {name}!";
}
There are 2 ways to see them(do not need to publish to azure):
1.Nav to azure portal -> app insights -> search , and it may take a few minutes to show them:
2.In visual studio output window, it can show asap:
Upvotes: 2