Writing Logs



  • The WebJobs Dashboard shows logs in two places: the page for the WebJob, and the page for a particular WebJob invocation.

Output from Console methods that you call in a function or in the Main() method appears in the Dashboard page for the WebJob, not in the page for a particular method invocation. Output from the TextWriter object that you get from a parameter in your method signature appears in the Dashboard page for a method invocation.

  • To write application tracing logs, use Console.Out (creates logs marked as INFO) and Console.Error (creates logs marked as ERROR).
public static void WriteLog([QueueTrigger("logqueue")] string message, TextWriter logger)
{
    Console.WriteLine("Console.Write - " + message);
    Console.Out.WriteLine("Console.Out - " + message);
    Console.Error.WriteLine("Console.Error - " + message);
    logger.WriteLine("TextWriter - " + message);
}
click below button to copy the code. By azure tutorial team
  • Which will result in these messages in the Dashboard for the WebJob:
[07/28/2016 22:29:18 > 0a1c35: INFO] Console.Write - Hello world!
[07/28/2016 22:29:18 > 0a1c35: INFO] Console.Out - Hello world!
[07/28/2016 22:29:18 > 0a1c35: ERR ] Console.Error - Hello world!
click below button to copy the code. By azure tutorial team
  • And this message in the Dashboard page for the method:
TextWriter - Hello world!
click below button to copy the code. By azure tutorial team

Related Searches to Writing Logs