.NET TraceSource not working under Windows Azure

I am trying to display some TraceSource registration TraceSource in an Azure emulator (console) window.

None of the TraceSource lines are displayed. Only Trace stock lines and various low-level azure messages.

Here are my repo actions, including code snippets:

  • File → Create → Cloud Service (SDK 2.0) → (add worker role).
  • Add TraceSource to WorkerRole.
  • Update the app.config file with the trace data.
  • Play / Publish.

NOTE all other default codes are there, for example, .csfg , which says UseDevelopmentStorage=true , etc.

Worker role code.

This is STOCK DEFAULT code code with added TraceSource code ...

 using System.Diagnostics; using System.Net; using System.Threading; using Microsoft.WindowsAzure.ServiceRuntime; namespace WorkerRole1 { public class WorkerRole : RoleEntryPoint { private TraceSource _traceSource; public override void Run() { _traceSource.TraceEvent(TraceEventType.Verbose, 0, "********************** 111111111111111111111 ******************* "); // This is a sample worker implementation. Replace with your logic. Trace.TraceInformation("WorkerRole1 entry point called", "Information"); while (true) { _traceSource.TraceEvent(TraceEventType.Verbose, 0, "********************** 222222222222222222222 ******************* "); Thread.Sleep(10000); Trace.TraceInformation("Working", "Information"); } } public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. _traceSource = new TraceSource("Azure.WorkerRole", SourceLevels.All); return base.OnStart(); } } } 

Now app.config ...

 <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <sharedListeners> <add name="AzureListener" type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <filter type="" /> </add> </sharedListeners> <sources> <source name="Azure.WorkerRole" switchValue="Verbose" > <listeners> <add name="AzureListener" /> </listeners> </source> </sources> </system.diagnostics> </configuration> 

What is it! run and make sure that the TraceSource material TraceSource not displayed :( Trace.Information is .. but I do not want to use the old Trace method, because it is suggested to replace it with TraceSource instead.

Output example. Please note that only Trace lines are added (along with low-level azure material).

enter image description here

+4
source share

Source: https://habr.com/ru/post/1485722/


All Articles