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?