Search code examples
azureazure-worker-rolesazure-diagnostics

How to use Trace Diagnostics in Azure Project


In my solution,I have one Azure worker role project and a class library(which deals with socket programming need for my project).When I deployed the solution on hosted service,something it is going wrong.Everything works like charm on Local dev storage.

I have included Trace Diagnostics in Azure Worker role.How I trace the error occured in class library since i can not use Trace over class library(when used it did not write to Storage table).

Is there any way how can debug the class library hosted on Azure along with Worker role

Regards, Vivek


Solution

  • You can still use System.Diagnostics module in your class library to generate custom trace messages. these message considered a Trace message and sent to Azure Storage if Diagnostics Monitor is configured correctly. In Windows Azure application the DiagnosticMonitorTraceListener collects all the calls to System.Diagnostics.Trace or System.Diagnostics.Debug in your application as well as other modules within your application. If it is not happening you may need to investigate why.

    There is another option is to add custom logging in your class library and then store all of these logs to a specific folder and sync the logs in this folder to blob/table Storage via Azure Diagnostics. Adding custom diagnostics to Azure Role is described here, this article is old but still applicable.