Share via

Custom Logs Visible in Live Metrics but Not in Application Insights Traces - Azure Function Project

Bosen Zhang 0 Reputation points
2024-08-09T18:02:38.8866667+00:00

Hello Azure Community,

I'm encountering an issue with logging custom informational messages in my Azure Function project. I've set up Application Insights to capture telemetry, and I can see the custom log messages appearing in the Live Metrics under the Sample Telemetry tab. However, when I try to query these logs in Application Insights > Logs > traces, the messages do not appear.

Here's my current setup:

Program.cs Configuration:


IHost host = new HostBuilder()
    .ConfigureFunctionsWebApplication()
    .ConfigureServices(services =>
    {
        services.AddApplicationInsightsTelemetry(options =>
        {
            options.ConnectionString = "my_connection_string";
            options.EnableAdaptiveSampling = false; // Disable adaptive sampling
        });
        services.ConfigureFunctionsApplicationInsights();
        services.Configure
Azure Monitor
Azure Monitor

An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

1 answer

Sort by: Most helpful
  1. hossein jalilian 13,360 Reputation points Volunteer Moderator
    2024-08-09T20:36:56.24+00:00

    Hello Bosen Zhang,

    Thanks for posting your question in the Microsoft Q&A forum.

    It looks like you're doing most things correctly, but there are a few potential issues and adjustments you might need to consider:

    • Ensure that your logging levels are configured correctly. You've set the minimum level to LogLevel.Information, which should be sufficient for capturing informational logs.
    • In Azure Functions, the default telemetry configuration should be enough for most scenarios. However, if you have custom configurations or want to ensure that your TelemetryClient is set up properly
    • Double-check the connection string in your AddApplicationInsightsTelemetry configuration.
    • Logs may take a few minutes to appear in the Application Insights portal. If your logs are not showing up, ensure that you’re not filtering out the logs by mistake when querying.

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

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