1

For application logging I have used Semantic Logging but I want to save logging into Azure table storage, now I just displayed it on Console.

static void Main(string[] args)
        {

            //create a listner and subscribe to event source
            var listener1 = ConsoleLog.CreateListener();
            MyEventSource Log = new MyEventSource();
            listener1.EnableEvents(Log , EventLevel.Verbose);

            //log 
            Log.ApplicationStart("Start console", "user 1");

            var ordersProcessed = 0;

            for (int i = 0; i < 10; i++)
            {
                ordersProcessed++;
                Console.WriteLine("Order no {0} is processed " , ordersProcessed);
            }
            
            //log 
            Log.ApplicationEnd("Finished", ordersProcessed);


            Console.ReadLine();

        }



class MyEventSource : EventSource
    {

        [Event(100,Message="Application Started..")]
        public void ApplicationStart(string startMessage, string userName)
        {
            if (this.IsEnabled()) //helps to avoid processing events that no listeners have been configure for
            {
                WriteEvent(100, startMessage, this.MyUtilityMethod(userName));                
            }
        }

        [Event(500, Message = "Application Ended..")]
        public void ApplicationEnd(string endMessage, int ordersProcessed)
        {
            if (this.IsEnabled()) //helps to avoid processing events that no listeners have been configure for
            {
                WriteEvent(500, endMessage, ordersProcessed);   
            }
        }

        //demonstrate method which are not part of EventSource contract
        private string MyUtilityMethod(string userName)
        {
            return string.Format("User {0} " , userName);
        }

    }

How can I save log into Azure table storage?

halfer
  • 19,824
  • 17
  • 99
  • 186
Neo
  • 15,491
  • 59
  • 215
  • 405

1 Answers1

2

I think this blog post might help - https://robindotnet.wordpress.com/2014/07/19/implementing-slab-in-an-azure-service/

mcollier
  • 3,721
  • 15
  • 12
  • My question is can I use Semantic logging with Azure Websites ? because ETA is not supported with Azure website . msdn link http://azure.microsoft.com/en-us/documentation/articles/choose-web-site-cloud-service-vm/ – Neo Feb 13 '15 at 17:44