In a previous post, I showed you How to enable Azure Web App diagnostic logs. These logs provide an excellent way to detect problems and analyze how your application works. In this post, I want to show you how to retrieve diagnostic logs using command-line tools.

As I mentioned in the previous post, There are two categories of diagnostic logs:

Application diagnostic logs

Record the messages generated by your application code. When you enable application logs, you must specify the log level: error, warning, information, and verbose and storage location: file system or Azure Storage blobs.

Web Server diagnostic logs

These Logs contain information produced by the web server that the Web App is running on. There are three types of diagnostic logs that you can enable and each of them is stored in a different directory as shown below.

  • Web server logging ⇒ d:\home\logfiles\http\rawlogs\
  • Detailed Error Messages ⇒ d:\home\logfiles\DetailedErrors\
  • Failed request tracing ⇒ d:\home\logfiles\W3SVC<Random#>\


  • This tutorial assumes that you already have a Microsoft Azure account configured.
  • You already have a Web Apps created and properly configured. If you want to know how to create it, see this link.

Azure CLI Workaround

In this case, we will use Azure Cloud Shell, a browser-based shell built into Azure Portal. This allows us to use the Azure command-line tools (Azure CLI and Azure PowerShell) directly from a browser. If you want to know more about Azure Cloud Shell, check out this link

Set the variables

Here, we define the characteristics of our environment and the resource’s properties.

With the following command, we store the name of the web app in a variable. Keep in mind that if you have more than one web application, you must modify the index number to correspond to the desired WebApp.

View Live Application Logging

Using log streaming is a quick way to view logged messages to troubleshoot your web application. To open the log stream generated by your web app, you should use the following command.

Azure webapp log tail

Retrieve Application Log Files

Here, using the following command you can retrieve the recorded information, ready for offline analysis. The application logs will automatically be compressed into a file. Then this file will be downloaded to the same directory where you run the command.
To retrieve all the diagnostics logs in a zip file, you should use the following command.

If you want to use a different path or name for the zip file, you should use the parameter –log-file.
diagnostic logs
To download the zipped log files to your local computer, use the file download and upload tool on the Azure Cloud Shell toolbar.

Thanks for reading my post. I hope you find it useful.

If you want to know more about Azure Web Apps, check out this link: