问题
So I have tried:
Trace.TraceInformation("Trace.Information Found message on queue");
Debug.WriteLine("Debug Found message on queue");
Trace.WriteLine("Trace.WriteLine Found message on queue");
Console.WriteLine("Console.WriteLine Found message on queue");
But neither of them outputs to the Azure portal Web Jobs output log.
What am I missing?
回答1:
Later edit: Since the Beta version, the answer below is no longer correct. In order to log messages, you have to use a TextWriter now as shown in these samples: https://github.com/Azure/azure-webjobs-sdk-samples/blob/master/BasicSamples/MiscOperations/Program.cs
Console.WriteLine should work. If that doesn't work, can you please post more code?
For messages written from inside a function, the logs should show up on the function invocation page.
For messages written outside of a function, the logs should show up in the job output log.
回答2:
Console.WriteLine worked for me but log.WriteLine (as per the SDK samples) did not.
Turned out I needed to set the Webjob connection strings in the portal even though I had AzureWebJobsDashboard and AzureWebJobsStorage defined in the App.config.
来源:https://stackoverflow.com/questions/23961594/how-can-i-do-logging-in-azure-web-jobs