Scott Hanselman has written a very interesting post about viewing/streaming trace logs from Windows Azure hosted websites on my dev machine:
http://www.hanselman.com/blog/StreamingDiagnosticsTraceLoggingFromTheAzureCommandLinePlusGlimpse.aspx. He has good arguments why to use Tracing in your code. With Windows Azure you have the possibility to look at the trace output with in realtime and without downloading log-files via FTP. But thats not very flexible, its slow and you don't see the data in real time.
This is a quick overview of a new REAL TIME Logstream feature, how to use it an how to integrate it with Royal TS.
I want to describe the issues I had with configuring this for my azure-hosted website as well as how to view the logstream without the Azure Command Line tools installed.
1) Setup your windows azure website
I will not go into details here - any tutorial out there will do - e.g. this one. Make sure you published to Windows Azure and can view your website over an *.azurewebsites.net URL)
2) Add tracing
For this, you can check Scotts Blogpost . Test until "azure site log tail mysite" works when you call ./trace.axd
3) Configure a deployment user
In the dashboard of your website click "set up deployment credentials" to setup a new user for deployments. See more documentation here.
4) Checkout the Kudu project
Kudu is the engine behind git deployments for Windows Azure websites. It is open source (Apache Licence 2.0) and can be used locally in your own datacenter if you wish to).
Behind every azure-hosted website, there is a kudu-service site. As an example:
Your website: http://azurelogstreaming.azurewebsites.net
The corresponding Kudu service site is https://azurelogstreaming.scm.azurewebsites.net.
Note: the https-protocol and the .scm. in the middle of the URL. The https is needed since you are required to send username/password over the wire. For more information about Kudu service urls read https://github.com/projectkudu/kudu/wiki/Accessing-the-kudu-service.
In order to stream the Trace information to your browser/command line window, you have to connect to the Kudu-URL and /logstream at the end.
In the Kudu Dashboard you can see the various REST endpoint URLs and also there is a nice Diagnostic console! It's still an experimental feature, but you can see what the backend already alows... I wonder, if we see an integration with Visual Studio here in the future... (you can even edit the files on the server in the console)
If you want to know more about the Kudu Project, there is a series of Channel9 posts about Kudu.
5) Enjoy live trace messages
Scott showed how you can grab the trace output via the Windows Azure Cross-Platform Command Line Tools.
But there is no magic involved - Kudu is just a regular http endpoint that you can access - so there is many other ways to display the output - sweet!
Option 1: Use a Web browser
Just point your browser to https://azurelogstreaming.scm.azurewebsites.net/logstream and enter the login/password you have just configured in step 3)
Since browsers buffer content until they get a complete document (which will never happen in this case) or they get a large amount of data you wont see output immediately. It is recommended to use curl or any other command line toll that does not buffer.
Option 2: Use curl and the Command line
You can also display the trace output via a standard curl call (curl is a command line URL transfer library that works with http, ftp and many more):
curl -u deploymentuser https://azurelogstreaming.scm.azurewebsites.net/logstream -k
Option 3: Use PowerShell
After installing the powershell tools for Windows Azure (which you can download via the Web Platform Installer or find them here) you can simply issue the following command to show the trace output:
Get-AzureWebSiteLog -Name websitename -Tail
Use the -Message parameter to filter for specific events, use the -Path parameter to filter for specific log types.
Integration in Royal TS
There are neat ways to integrate this in Royal TS: You could launch the Kudu Diagnostics page from within Royal TS:
... or display the Logstream of your Web site in realtime: