Do Azure Your One Stop Hub to learn about Cloud (Microsoft Azure, AWS & Google Cloud)

Streaming Diagnostics Logs of ASP.NET Web App Hosted on Azure App Service using KUDU, PowerShell and Visual Studio 2015


We welcome you once again. We try mostly to talk about those features which are least explored by users of Azure. Today we are going to talk about live log streaming from site in production which is hosted on Azure App Service as Web App. To get log streams
it’s necessary to enable logging from Azure Portal. Once you do that you can stream logs either from log console in portal, using Powershell, using Visual Studio output console with Azure SDK installed or using KUDU’s live log stream. It’s one of the up tapped
area by most of developers who use Azure App Service. We’ll start from scratch right by creating a new project in Visual Studio of ASP.NET Web App and host it to Azure right from Visual Studio and then tap into options available for streaming logs.

Creating ASP.NET Web App in Visual Studio

Lets start by creating a simple ASP.NET application,

Create a new ASP.NET Project and now once you have created the WebApp you just need to publish that to the Web App to Microsoft Azure. Make sure you publish your site in release configurations in case you need to attach remote debugger to live site. On your
project you just need to right click and click on Publish. It would take you to the wizard that you can follow to create Web App on Azure and publish your current template. Here blog in the images are the steps to follow,

  • Publish Site
  • Creating Web App
  • Web App Creation Wizard
  • Resource Group Selection
  • Live Site



To add log, you may add following code to your respective ViewController. This log would be logged if and only if your logging level is Verbose i.e. log everything.

Once you have added this code or your respective log, you need to publish once again so that it’s live. Once you have done this you can got to Azure Portal to change the settings for logging. This step can be performed before publishing your Web App to Azure
first time.

Azure Portal Settings

To enable live log streaming you need to tweak setting from Azure Portal of respective Web App.

Go to Azure portal and search for log, Once you are able to locate Diagnostic logs option. Click on it and you would see Settings blade for Diagnostics logs.

For sake of logging everything I am turning on everything. You can do that respective to your needs. As I am using Trace.WriteLine(), it wont be logged if I use any of the logging level except verbose. Save your settings and now you are ready to stream logs
from your live website.

Streaming Logs from Azure Web App

Glad you made it till here, as you have turned on setting from Azure Portal for Diagnostic logs. There are several ways to stream them live. You can use Azure Portal itself to stream logs, or may be your favorite IDE i.e. Visual Studio, or may be PowerShell
or our favorite SCM tool KUDU which is always with your Azure Asp.NET web App. Let’s discuss each option individually below.

Log Streaming via Azure Portal

While you were setting Log Settings for particular Web App, you would have noticed that there is another options related to log. That is Log Stream. If you click over that, a blade would open with console in it. It would display your logs, just refresh your
web app and you would be able to see logs live from web site.

Trace Log we entered earlier.

Log Streaming via Visual Studio

Visual Studio is an amazing IDE it supports streaming logs from site in production in Visual Studio. You just need to follow these steps,

  • Go to Server Explorer
  • Add You Azure Account by Signing In
  • Expand App Service under your subscription and you would be able to find your website.
  • Right click over it and you can click on the option of View Streaming Logs.
  • That’s all you need to do, just refresh your web site and you would be able to see logs in your output console.

In Case you wan to access all actions you would be able to see them below your server explorer tab, all actions would be visible to you either it’s about logs or about debugging site in production.

Log Streaming via PowerShell

PowerShell is always amazing CLI and really powerfull. If you have installed Azure CLI tools you would be able to view streaming logs on your console using Azure CMD or PowerShell. Once you login and authenticate your powershell CLI you type in following line
mentioned below to get live log streams.

Command to Execute, Get-AzureWebsiteLog -Name doazure -Tail

Log Streaming via KUDU ( SCM )

In last article I talked about
which is behind deployments of Azure Web App and is also used for diagnostics. If you just go to tools and click on “log stream” you would be able to see live log streams in browser. Refresh your web app and BOOM!

Live Diagnostic logs in browser windows


With Azure App service and its logging facilitation available inside Visual Studio, in KUDU, PowerShell and in Azure Portal itself make easy for developer to stream logs live from site in production. This is all for this time, hope to see you next time with
another technical article.

About the author

Saad Mahmood

Add comment

Do Azure Your One Stop Hub to learn about Cloud (Microsoft Azure, AWS & Google Cloud)

Saad Mahmood

Get in touch

I am 23, with over half a decade of familiarity with Software Development. My first IDE was Visual Studio and I started my journey of software development with C#. I am Microsoft's MVP for Windows Development and Xamarin's as well, which makes me contribute to Xamarin and Windows ecosystem. A man is known by its software delivery, and I believe I have done it many times. Not only having knowledge of Microsoft stack but also knowledge of JAVA, Python(dJango, Flask) makes me diverse. I believe what comes to one's mind is always possible.