Azure Trace Logs work on the emulator, but do not work on the cloud

I have a TraceManager class that basically calls the TraceEvent method from the System.Diagnostics.TraceSource class.

TraceSource source = new TraceSource("MyTraceSource"); void TraceInternal(TraceEventType eventType, string message) { if (source != null) { try { source.TraceEvent(eventType, (int)eventType, message); } catch (SecurityException) { //Cannot access to file listener or cannot have //privileges to write in event log //do not propagete this :-( } } } public void TraceError(string message) { if (String.IsNullOrEmpty(message)) throw new ArgumentNullException("message", Messages.exception_InvalidTraceMessage); TraceInternal(TraceEventType.Error, message); } 

So, to track the error, I call the TraceError method.

Well, this is the code that I use in the WebRole OnStart method:

 DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration(); TimeSpan transferPeriod = TimeSpan.FromMinutes(1.0); dmc.Logs.ScheduledTransferPeriod = transferPeriod; dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc); 

This is my configuration in my web.config:

 <system.diagnostics> <sources> <source name="MyTraceSource" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch"> <listeners> <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics"> <filter type="" /> </add> </listeners> </source> </sources> <switches> <add name="sourceSwitch" value="Verbose"/> </switches> </system.diagnostics> 

And these are my settings for my WebRole:

 <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=ValidAcountName;AccountKey=ValidAcountKey" /> </ConfigurationSettings> 

And finally, I have a diagnostic import in my ServiceDefinition:

 <Imports> <Import moduleName="Diagnostics" /> </Imports> 

When I run my application from Visual Studio under Azure emulators, it works fine. Even I can change my ConfigurationSettings to save my logs in a storage emulator or in my cloud storage. But when I breed him on the azure, I do not see any magazine.

Any ideas?

+4
source share
2 answers

Could you check the properties of your Azure project if the following setting is active? If so, try disabling it:

enter image description here

Link: http://michaelcollier.wordpress.com/2012/04/02/where-is-my-windows-azure-diagnostics-data/

+1
source

Have you confirmed that you define the TRACE constant when creating the application? If you have a custom script assembly, is it possible that this constant is undefined?

This will prevent the registration of trace statements.

0
source

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


All Articles