How do I write to the logs in Azure WebJobs from a C# console app?

后端 未结 2 1721
一个人的身影
一个人的身影 2020-12-08 12:56

I\'m testing out Azure Webjobs. I wrote a console application which polls a SQL database for new work and processes it. I\'m not using the WebJobs SDK because it only supp

2条回答
  •  感情败类
    2020-12-08 13:37

    I was able to get Console.WriteLine() to leave messages in my web job log. The following console runs and leaves log messages.

    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                DoStuff();
                Thread.Sleep(10000);
            }
        }
    
        public static void DoStuff()
        {
            Console.WriteLine("do stuff");
        }
    }
    

    This is what my log file shows:

    [03/15/2014 04:05:28 > cf6d00: SYS INFO] Run script 'HelloWebJobConsoleApplication.exe' with script host - 'WindowsScriptHost'
    [03/15/2014 04:05:28 > cf6d00: SYS INFO] Status changed to Running
    [03/15/2014 04:05:28 > cf6d00: INFO] do stuff
    [03/15/2014 04:05:38 > cf6d00: INFO] do stuff
    [03/15/2014 04:05:48 > cf6d00: INFO] do stuff
    [03/15/2014 04:05:58 > cf6d00: INFO] do stuff
    

提交回复
热议问题