且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何查看在Azure平台上部署的Azure工作角色上的跟踪日志

更新时间:2023-11-30 16:09:46

如果您使用的是Trace,则可以让Azure移动跟踪日志自动为您提供Azure诊断存储帐户.您只需要在自己的计算机中配置诊断程序 角色(Web或辅助角色)以传输日志.

要在您的代码中添加跟踪语句:

  1. 打开应用程序的源文件.例如,用于工作角色或Web角色的.cs文件.
  2. 在要捕获有关状态信息的位置添加Trace语句应用.您可以使用多种方法来格式化Trace语句的输出. 有关更多信息,请参见如何:将跟踪语句添加到应用程序代码中.
  3. 保存源文件.

有关详细信息,请参见以下链接:

--------------- -------------------------------------------------- ------------------------------

如果此答案有帮助,请单击标记为答案"或向上" -投票".要提供有关您的论坛体验的其他反馈,请单击 在这里 >>

I created a worker role using Azure cloud service template and just added some trace logs.

I could see the trace logs on output window of Visual studio.

Then I deployed on Azure portal and was able to see the status of the Worker role running.

Now, I am not finding any option to see the same traces on Azure portal.

Is there any option to view the trace logs on portal?

If you're using Trace, you can have Azure move the trace logs for you automatically to Azure diagnostics storage account. You'll just need to configure Diagnostics in your Role (Web or Worker Roles) to transfer Logs.

To add trace statement to your code:

  1. Open a source file for your application. For example, the .cs file for the worker role or web role.
  2. Add the following using statement if it has not already been added: using System.Diagnostics;
  3. Add Trace statements where you want to capture information about the state of your application. You can use a variety of methods to format the output of the Trace statement. For more information, see How to: Add Trace Statements to Application Code.
  4. Save the source file.

For more details, you may refer the below links:

https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-dotnet-diagnostics-trace-flow

https://docs.microsoft.com/en-us/azure/vs-azure-tools-diagnostics-for-cloud-services-and-virtual-machines#turn-on-diagnostics-in-cloud-service-projects-before-you-deploy-them

-----------------------------------------------------------------------------------------------

If this answer was helpful, click "Mark as Answer" or "Up-Vote". To provide additional feedback on your forum experience, click here