0
0
AzureHow-ToBeginner · 4 min read

How to View Logs in Azure App Service Easily

To view logs in Azure App Service, use the Log Stream feature in the Azure Portal for real-time logs or enable Application Logging to save logs to storage. You can also use Azure CLI commands like az webapp log tail to stream logs directly to your terminal.
📐

Syntax

Here are common ways to view logs in Azure App Service:

  • Azure Portal Log Stream: Navigate to your App Service > Log stream to see live logs.
  • Enable Application Logging: Turn on logging in App Service logs settings to save logs to file system or blob storage.
  • Azure CLI Command: Use az webapp log tail --name <app_name> --resource-group <resource_group> to stream logs in terminal.
bash
az webapp log tail --name <app_name> --resource-group <resource_group>
💻

Example

This example shows how to stream logs from an Azure App Service using Azure CLI.

bash
az webapp log tail --name myappservice --resource-group myresourcegroup
Output
2024-06-01T12:00:00.000Z INFO Starting log stream... 2024-06-01T12:00:01.000Z INFO HTTP GET /api/values responded 200 2024-06-01T12:00:05.000Z ERROR Exception occurred in processing request
⚠️

Common Pitfalls

  • Not enabling logging in App Service settings before trying to view logs.
  • Using az webapp log tail without specifying the correct app name or resource group.
  • Expecting logs immediately after enabling logging; sometimes it takes a few minutes to start capturing logs.
  • Confusing Log stream with saved logs; stream shows live logs but does not save them.
bash
Wrong:
az webapp log tail --name wrongapp --resource-group wronggroup

Right:
az webapp log tail --name myappservice --resource-group myresourcegroup
📊

Quick Reference

MethodDescriptionHow to Access
Log StreamView live logs in real-timeAzure Portal > App Service > Log stream
Application LoggingSave logs to file system or blob storageAzure Portal > App Service > App Service logs
Azure CLIStream logs in terminalaz webapp log tail --name --resource-group

Key Takeaways

Enable logging in App Service settings before viewing logs.
Use Azure Portal Log Stream for real-time log viewing.
Use Azure CLI command 'az webapp log tail' to stream logs in terminal.
Logs may take a few minutes to appear after enabling logging.
Ensure correct app name and resource group when using CLI commands.