ILogger structured loggig with Application Insights not working in .Net 5 Azure Function

Dietmar 111 Reputation points
2021-04-26T11:25:14.14+00:00

Following the guide of creating the HttpExample for .Net 5 based Azure Functions, I'm failing setting up structured logging.

My relevant code is:

[Function("HttpExample")]  
public static HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req, FunctionContext executionContext)  
{  
    var logger = executionContext.GetLogger("HttpExample");  
    logger.LogInformation("Example {ExampleValue}", 1001);  

I would expect to get a logging record in Application Insights with a customDimensions property prop__ExampleValue, with a value of 1001.

This is however not the case. No matter what I try, I get the log entry as simple string, but not split into custom name/value pairs.

Any help would be highly appreciated.

Thanks in advance,
Dietmar

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,929 questions
{count} votes

1 answer

Sort by: Most helpful
  1. colinrippeyfinarne 26 Reputation points
    2021-09-01T14:22:52.393+00:00

    Hi @Dietmar

    I think I am seeing the same issue as you.

    I am porting some simple in-process functions from a dotnet 3.1 function app to a new isolated .net 5 function app.

    I am making simple log statements such as the one you have detailed above but when I check in app insights the structured logging capabilities are not working.

    Looks like it is an active issue being tracked here:

    https://github.com/Azure/azure-functions-host/issues/7452

    The fix is tentatively scheduled for today based on sprint 108:

    https://github.com/Azure/azure-functions-host/milestone/141

    Maybe we'll get an update later today.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.