Thursday, October 27, 2016

Viewing streaming logs using Azure PowerShell & using Site Control Manager

Using the Get-AzureWebsiteLog cmdlet, you can stream logs directly in the Azure PowerShell console window. The code shown here connects to the log-streaming service to start streaming the web server logs.

Get-AzureWebsiteLog -Name "contoso-web-west" -Tail -Path http


The Get-AzureWebsiteLog also supports a Message parameter that you can use to ilter
the output when streaming application logs. For example, the code shown here ilters the
log-streaming output to just application logs that are categorized as errors.


Get-AzureWebsiteLog -Name "contoso-web-west" -Tail -Message Error


 

Viewing streaming logs using Site Control Manager 

The log-streaming service is available in the Site Control Manager as an option in the Tools menu, as shown in Figure
 
The Tools menu in Site Control Manager showing the Log Stream option

Viewing streaming logs using the management portal

The streaming log service is accessible from the Website blade of your website. Scroll down to the Operations section where you will see the Streaming Logs part, as shown in Figure


The Streaming Logs part on the Website blade of the management portal

In the Streaming Logs blade, you can toggle between application and web server logs,pause and start the log-streaming service, and clear the logs in the console. Figure shows example output for the web server logs in the Streaming Logs blade

The Streaming Logs blade showing web server logs


Using Azure PowerShell to retrieve log files

You can download all the log iles using the Azure PowerShell cmdlet Save-AzureWebsiteLog, as shown in the code below. This code will download the log iles and store them in E:\Weblogs.zip on the client computer.
$wsName = "contoso-web"
Save-AzureWebsiteLog -Name $wsName -Output e:\weblogs.zip

NOTE :: SAVING LOG FILES TO LOCAL COMPUTER USING POWERSHELL
Using the Save-AzureWebsiteLog cmdlet to download log files will download all logs except the Failed Request logs. If you use this method for retrieving log files, you will need to use one of the other options to retrieve failed request logs separately.


Using Site Control Manager (Kudu) to retrieve log files

Site Control Manager, often referred to as ”Kudu”, is a website extension that you can use to retrieve log files, browse the file system, edit files, delete files, view environment variables,and even capture diagnostic dump files.

To access the Site Control Manager, open your browser and navigate to
https://.scm.azurewebsites.net

Note : Every Azure website gets the Site Control Manager site extension installed by default.There is nothing you have to do to enable it.

The URL is the same as the URL for your website, with the added scm. immediately after the website name. Figure is an example of what the Site Control Manager screen looks like for a website.


The home page of the Site Control Manager site extension

Using Site Control Manager, select the Debug Console and then select the CMD option.This opens a debug console that you can type directly into or use the navigation above. As you click the navigation links, the debug console will update to your current directory. Figure shows the debug console screen and the contents of the Log Files folder.
The debug console in Site Control Manager and viewing the Log Files folder

Using Site Control Manager, you can download an entire folder or individual iles by clicking
the download link to the left of the directory or ile name.

Featured Posts

Adding Accesspolicy to KeyVault for Service Principal Using Portal and Powershell

  Scripts path : https://drive.google.com/drive/folders/1sbBpnVFgXhUIXLdf2E9heyWDeU2f9427?usp=sharing  Adding Accesspolicy to KeyVault for S...