Using az containerapp logs shows recent logs, but for troubleshooting historical logs, you need to use Log Analytics.
First, retrieve the workspace ID of the Log Analytics.
WORKSPACE_ID=$(az containerapp env show -n $ACA_ENVIRONMENT -g $RESOURCE_GROUP \
--query properties.appLogsConfiguration.logAnalyticsConfiguration.customerId -o tsv)
echo "Workspace ID: $WORKSPACE_ID"
WARNING: The behavior of this command has been altered by the following extension: containerapp
Workspace ID: [REDACTED]
Then use az monitor log-analytics query and provide the workspace ID and the container ap pname. The command below retrieves the last 20 log entries.
az monitor log-analytics query -w $WORKSPACE_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == '$CONTAINER_APP_NAME' | project TimeGenerated, Log_s | order by TimeGenerated desc | take 20" \
-o table
Log_s TableName TimeGenerated
---------------------------------------------------------------------------- ------------- ----------------------------
[2026-08-24 10:04:09 +0000] [9] [INFO] Worker exiting (pid: 9) PrimaryResult 2026-08-24T10:04:10.7729608Z
[2026-08-24 10:04:09 +0000] [8] [INFO] Worker exiting (pid: 8) PrimaryResult 2026-08-24T10:04:10.7729608Z
[2026-08-24 10:04:09 +0000] [7] [ERROR] Worker (pid:8) was sent SIGTERM! PrimaryResult 2026-08-24T10:04:10.7729608Z
[2026-08-24 10:04:09 +0000] [7] [INFO] Handling signal: term PrimaryResult 2026-08-24T10:04:10.7729608Z
[2026-08-24 10:04:09 +0000] [7] [INFO] Shutting down: Master PrimaryResult 2026-08-24T10:04:10.7729608Z
[2026-08-24 10:00:05 +0000] [8] [INFO] Worker exiting (pid: 8) PrimaryResult 2026-08-24T10:00:06.590624Z
[2026-08-24 10:00:05 +0000] [7] [ERROR] Worker (pid:8) was sent SIGTERM! PrimaryResult 2026-08-24T10:00:06.590624Z
[2026-08-24 10:00:05 +0000] [7] [INFO] Handling signal: term PrimaryResult 2026-08-24T10:00:06.590624Z
[2026-08-24 10:00:05 +0000] [9] [INFO] Worker exiting (pid: 9) PrimaryResult 2026-08-24T10:00:06.590624Z
[2026-08-24 10:00:05 +0000] [7] [INFO] Shutting down: Master PrimaryResult 2026-08-24T10:00:06.590624Z
[2026-08-24 09:59:27 +0000] [7] [INFO] Using worker: sync PrimaryResult 2026-08-24T09:59:28.9909682Z
[2026-08-24 09:59:27 +0000] [7] [INFO] Starting gunicorn 21.2.0 PrimaryResult 2026-08-24T09:59:28.9909682Z
[2026-08-24 09:59:27 +0000] [9] [INFO] Booting worker with pid: 9 PrimaryResult 2026-08-24T09:59:28.9909682Z
[2026-08-24 09:59:27 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7) PrimaryResult 2026-08-24T09:59:28.9909682Z
[2026-08-24 09:59:27 +0000] [8] [INFO] Booting worker with pid: 8 PrimaryResult 2026-08-24T09:59:28.9909682Z
[2026-08-24 09:58:53 +0000] [7] [INFO] Listening at: http://0.0.0.0:8000 (7) PrimaryResult 2026-08-24T09:58:55.7719235Z
[2026-08-24 09:58:53 +0000] [7] [INFO] Starting gunicorn 21.2.0 PrimaryResult 2026-08-24T09:58:55.7719235Z
[2026-08-24 09:58:53 +0000] [8] [INFO] Booting worker with pid: 8 PrimaryResult 2026-08-24T09:58:55.7719235Z
[2026-08-24 09:58:53 +0000] [7] [INFO] Using worker: sync PrimaryResult 2026-08-24T09:58:55.7719235Z
[2026-08-24 09:58:53 +0000] [9] [INFO] Booting worker with pid: 9 PrimaryResult 2026-08-24T09:58:55.7719235Z