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...
EDIT 2: Added screenshots of local execution and deployed one in portal.




appInsightsis the only way by which I can get the invocation logs? The functionality is already implemented and is usinglogbackto write logs. I'm trying to execute the same functionality with Azure functions. I would like to see the logs in invocation details. see image attached. But it only shows the context logger logs there. Should I use this context logger wherever I have to log something? You can see the log statements are in a different class. Similarly there are more logs in the execution flow. I've to see them. Does it blocks the log entries from other loggers? - Master Pomvn clean package. The commandmvn azure-functions:runis used to run it locally.mvn azure-functions:deployis used to deploy it. You can see that the statement <<<<<<<<<<<< INSIDE THE SERVICE HANDLE >>>>>>>>>>>> is visible when its run locally. But the log statements in the classMySampleServiceis not available when its deployed in portal (not available in log streaming or invocation details). - Master Po