【问题标题】:How do I store my Log into Azure table storage I used Semantic Logging如何将我的日志存储到 Azure 表存储中 我使用了语义日志记录
【发布时间】:2015-04-12 05:43:15
【问题描述】:

对于应用程序日志,我使用了Semantic Logging,但我想将日志保存到Azure table storage,现在我只是在控制台上显示它。

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);
        }

    }

谁能帮我将日志保存到 Azure 表存储中?

【问题讨论】:

    标签: azure azure-storage azure-web-roles azure-blob-storage semantic-logging


    【解决方案1】:

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-02
    • 1970-01-01
    • 2017-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多