tl;dr: If you want logging to work with Helios, you need to add some things to your web.config. Snippet at the bottom of this article.
For a project at work, I’m using Helios to host a small ASP.NET Web API on Azure Web Sites. If that sentence doesn’t make sense, you might need to do some extra reading first:
This setup works really well for us. Using OWIN with Web API hosted on IIS via Helios means we have a small amount of code to get the API running. Not only is the code small, it’s succinct and clear, because we don’t rely on large frameworks with side-effects and magic conventions.
Azure Web Sites provides easy to use logging. Application logging via the System.Diagnostics.Trace type is added automatically to Azure Tables and Blob Storage, and it’s then available via the Kudu Log Streaming Service. This doesn’t work for Helios out of the box. I did some debugging, and got as far as I needed to fix the bug without fully understanding the issue, as I couldn’t find the relevant code in Kudu. If anyone knows exactly why this doesn’t work out of the box, I’d love to know.
When you publish your ASP.NET project to Azure Web Sites, it automatically adds three new
TraceListeners to your app:
TraceListener types all exist in the
Microsoft.WindowsAzure.WebSites.Diagnostics.dll assembly. I can’t find any reference to the assembly online, so it must not be in the open-sourced part of Azure Web Sites. You can download it from your Azure Web Site using the sample project I have in GitHub.
Azure Web Sites doesn’t seem to have full support for Helios hosted apps yet, so won’t do the automatic injection of the listeners. This is easy to fix by including the following in your
1 2 3 4 5 6 7 8
Now you will have full application logging support in Azure Web Sites as if you were using a ‘real’ ASP.NET project. Hopefully this will help you avoid the three hours of debugging I did today.