Azure Functions with java – How to get the logs written within the function?

I’ve deployed a queue triggered azure function with Java in Azure. I’ve added logback-classic and lombok in pom.xml for logging.
But the logs are not displayed on the function’s monitor > invocation details or the log-streaming service in portal.
But I could see the logs written with context.getLogger(). The logs writter with logback logger is not visible. Please let me know how to check my logs in function invocation.

Following is the queue triggerred azure function handle

public class QueueHandlerFunction {

  @FunctionName("queuetriggertest")
  public void queueMessageHandler(@QueueTrigger(name = "msg",
      queueName = "my-test-queue", connection = "MyQStorage") final String payload,
      final ExecutionContext context) {

    //Logs with this logger is visible
    context.getLogger().info("Received Message From my-test-queue : " + payload);

    MySampleService.handleQueueMessage(payload);
  }
}

Following is the MySampleService class with lombok logger

@Slf4j
public class MySampleService {

  public static void handleQueueMessage(final String payload) {

    log.info("<<<<<<<<<<<< INSIDE THE SERVICE HANDLE >>>>>>>>>>>>");
    if (StringUtils.isNotBlank(payload)) {
        log.info("Received Payload : {}", payload); //This log not available
        // TODO Work with incoming payload
    } else {
      log.info("Message payload is Blank."); //This log not available
    }
  }

}

Following is he logback.xml placed in the resources folder of the maven project.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<configuration>
   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <encoder>
         <pattern>%d{E MMM dd yyyy hh:mm:ss a} [%thread] %-5level %logger{36}
                - %msg%n</pattern>
      </encoder>
   </appender>

   <logger name="com.isl.test" level="INFO" />
   <root level="INFO">
      <appender-ref ref="STDOUT" />
   </root>
</configuration>

And I’ve the following dependencies in the pom.xml

<dependencies>
        <dependency>
            <groupId>com.microsoft.azure.functions</groupId>
            <artifactId>azure-functions-java-library</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.7</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.20</version>
        </dependency>
    </dependencies>

EDIT: Attached portal screenshot for the function invocation logs…

Attached portal screenshot for the function invocation logs

EDIT 2: Added screenshots of local execution and deployed one in portal.

  • Logs in command prompt when is executed locally
    Command prompt when executed the function locally

  • Live streaming console service of the function from the portal for a new message in queue
    Portal Console with live streaming

  • Invocation details of the function from the portal for a new message in queue
    Portal Invocation details

Leave a Reply

avatar
  Subscribe  
Notify of