Trace.WriteLine in ASP.NET Azure

霸气de小男生 提交于 2019-12-10 13:06:50

问题


when I use

Diagnostics.Trace.WriteLine("message", "Information"); 

in my azure-asp.net this does not show up in my azure compute emulator, but if I do the same from my worker-role it works, any idea why?

Thanks!


回答1:


This is with SDK 1.3, right? In 1.3, web roles by default run with full IIS, which means your actual web app code is in a different app domain from your RoleEntryPoint. I believe the compute emulator only shows messages from RoleEntryPoint (WebRole.cs or WorkerRole.cs).

To double check, try putting a trace message in OnStart in WebRole.cs; I'm guessing it will show up.




回答2:


Add a TraceListener of the type :

Microsoft.ServiceHosting.Tools.DevelopmentFabric.Runtime.DevelopmentFabricTraceListener,
    Microsoft.ServiceHosting.Tools.DevelopmentFabric.Runtime, 
    Version=1.0.0.0, 
    Culture=neutral, 
    PublicKeyToken=31bf3856ad364e35

The reason is due to not having this TraceListener in the AppDomain of the ASP.NET application - which is different to where WebRole.cs runs. All changed in v1.3 with the introduction of full IIS.

http://blog.bareweb.eu/2011/01/tracing-to-azure-compute-emulator-sdk-v1-3/




回答3:


Use Trace.TraceInformation instead:

Writes an informational message to the trace listeners in the Listeners collection using the specified message.



来源:https://stackoverflow.com/questions/4496027/trace-writeline-in-asp-net-azure

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