Logs not appearing in Azure portal for Function using Logback, but visible with ExecutionContext

abazine abdellatif 0 Reputation points
2024-10-19T00:25:06.0366667+00:00

I'm experiencing an issue with logging in Azure Functions (Java). When I use ExecutionContext.getLogger(), my logs appear in both the Azure portal and the log stream. However, when I use Logback for logging, I can see the logs in the log stream, but they do not appear in the Azure portal's logs.

Here’s a summary of my setup:

  • Azure Functions with Java runtime.
  • Logback is configured correctly, and I see the logs in the log stream.
  • Logs written using ExecutionContext.getLogger() are visible in both the log stream and Azure portal, but the same is not true for Logback logs.

Is there a specific configuration required to ensure Logback logs are also visible in the Azure portal? Any insights or suggestions would be greatly appreciated!

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

1 answer

Sort by: Most helpful
  1. Pinaki Ghatak 4,610 Reputation points Microsoft Employee
    2024-10-21T09:44:37.6066667+00:00

    Hello @Abazinet

    When using Logback for logging, you need to ensure that the logs are written to the correct location. By default, Azure Functions logs are written to the console, which is why you can see the logs in the log stream.

    However, the Azure portal's logs are not the same as the log stream.

    To ensure that your Logback logs are visible in the Azure portal, you need to configure Logback to write the logs to a file. You can then configure Azure Functions to send these logs to Azure Monitor logs, which will make them visible in the Azure portal.

    Here are the steps to configure Logback to write logs to a file:

    1. Create a Logback configuration file (e.g. logback.xml) in your project's resources folder.
    2. Configure Logback to write logs to a file by adding the appropriate configuration

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.