Trace.WriteLine in ASP.NET Azure
when I use
Diagnostics.Trace.WriteLine("message", "Informa开发者_如何学编程tion");
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!
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.
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/
Use Trace.TraceInformation
instead:
Writes an informational message to the trace listeners in the Listeners collection using the specified message.
精彩评论