Logging is an important piece of functionality for any application because it helps tremendously with troubleshooting issues and health monitoring. A common technique is to write to log files, but they can get very large and difficult to inspect. I will show you the configuration steps needed to write to Azure Table Storage so that you can more easily consume the logging data your application provides.

The following steps assume you already have an application with NLog configured, but if you don’t you can download the sample application at the bottom of this article which includes everything you need to get started.

The first thing to do is add the Azure Table Storage NuGet package.

  • AzureTableStorageNLogTarget

You will have to go through the NuGet package manager and manually update the following packages for it to function correctly. I think there is a stale dependency issue with the main AzureTableStorageNLogTarget package which requires this. Hopefully this will be resolved in the future.

  • Window Azure Storage (8.6 or higher)
  • Microsoft Azure Key Valut (2.0 or higher)
  • Microsoft Azure Configuration Manager (3.2 or higher)

Add the configuration in the App.config or Web.config. This includes:

1) Add an extensions node within the nlog node

2) Add an new target in the targets node

3) Add a logger node within the rules node:

4) Add a connection string within the connectionStrings node with you own account name and account key. You can get these by setting up a new table storage instance within Azure.

Once you have your application setup and logging you can use a free tool from Microsoft called Table Storage Explorer to query your log data.

https://azure.microsoft.com/en-us/features/storage-explorer/

Here is a sample project from my github account
https://github.com/RyanOC/AzureTableStorageNLog

In a future post I will show how to query Azure Table Storage even more efficiently using LINQPad.