November 6 2015
I’ve never liked the default logging mechanisms in Azure for application event logging. Parsing the WADDiagnosticInfrastructureLogsTable is always such a hassle. Events I’ve written are mixed in with all the other events that Azure is firing all the time, and everything in my event is jammed into a single field.
So, for my current Azure project, I switched to using NLog and love it! I used the NLog extension for writing events to Azure table storage: https://github.com/abkonsta/NLog.Extensions.AzureTableStorage – you’ll notice that isn’t the master Git repository, but the master one https://github.com/harouny/NLog.Extensions.AzureTableStorage doesn’t have the right README.md updated! But I’m using 220.127.116.11 and it works great.
I am setting the connection string via code so that I pick up the string based on the local config or cloud config, aka
var azureStorageTarget = (AzureTableStorageTarget)
azureStorageTarget.ConnectionString = RoleEnvironment.GetConfigurationSettingValue
And wow so much better. Some of the overloads are so nifty, like the ability to just give the exception to the logger, or letting the logger do the string formatting. Nice!
Below is a sample project showing both a web role and a worker role using NLog and logging to table storage.
NLog4AzureCloudService.zip (495.15 kb)