How can I do logging in Azure Web Jobs? [duplicate]

断了今生、忘了曾经 提交于 2019-12-07 11:27:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!