Summary

Azure Log Manager allows you to store logs for your service APIs, applications or whatever into Azure table storage. A log viewer with stats is also available.

Features

  • Store information you want into Azure table storage
  • Store information and errors or only errors depending on configuration (service hosted on Azure)
  • Log Viewer displays IPs, stats and visits

Requirements

  • WPF Toolkit for Log viewer
  • Azure SDK 1.8

Getting started

  • Store Azure storage account connection string into Azure configuration, web.config or appconfig
  • Set up table storage
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageAccount"));

CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("logs");
table.CreateIfNotExists();

String logType = CloudConfigurationManager.GetSetting("LogType");

LogManager.Table = table;
LogManager.LogType = logType;

 

  • Log information you want
public String GetHelloWorld()
{
    Stopwatch sw = Stopwatch.StartNew();
    Boolean hasError = false;

    try
    {
        Thread.Sleep(2000);
    }
    catch (Exception ex)
    {
        hasError = true;
        LogManager.Log(ex.ToString(), LogEntity.LogType.Error, 0);
    }
    finally
    {
        sw.Stop();
        if (hasError == false)
        {
            LogManager.Log("GetHelloWorld", LogEntity.LogType.Message, sw.ElapsedMilliseconds);
        }
    }

    return "Hello World";
}
  • To use Log viewer, just set your Azure storage account connection string into App.config (AzureLogManager.LogBoard project)
  • In order to only log exceptions, clear the value of the “LogType” key in the Azure project

Screenshots

Daily visits

Quick stats about the last week

Details about visits

 

Aymeric Lagier

http://www.aymericlagier.com

@aymlagier

Last edited Dec 21, 2012 at 12:38 PM by aymericlagier, version 8