I've got an app that I've deployed with Azure, and I am trying to get plain vanilla Tracing working
I've gone through all of these articles:
https://stackoverflow.com/search?q=diagnosticmonitortracelistener
Here's my role entry point:
public class WebRole :RoleEntryPoint {
public override bool OnStart() {
if (RoleEnvironment.IsAvailable) {
LocalResource localResource = RoleEnvironment.GetLocalResource("MyCustomLogs");
DirectoryConfiguration dirConfig = new DirectoryConfiguration();
dirConfig.Container = "diagnostics-mycustomlogs-container";
dirConfig.DirectoryQuotaInMB = localResource.MaximumSizeInMegabytes;
dirConfig.Path = localResource.RootPath;
DiagnosticMonitorConfiguration diagMonitorConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagMonitorConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
diagMonitorConfig.Directories.DataSources.Add(dirConfig);
DiagnosticMonitor diagMonitor = DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagMonitorConfig);
Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
Trace.AutoFlush = true;
Trace.WriteLine("Role Starting");
}
return base.OnStart();
}
}
Also put the trace listener in global.asax.cs:
if (RoleEnvironment.IsAvailable) {
Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
Trace.AutoFlush = true;
}
I've also tried just pasting it directly into web.config
<trace>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener,
Microsoft.WindowsAzure.Diagnostics,
Version=1.8.0.0,
Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
This directory gets created in my Azure VM
C:\Resources\Directory\d63aeab4198d458a9c0b1d0f818e4054.CorpQna.Web.MyCustomLogs
This is in my ServiceDefinition.csdef
file:
<LocalResources>
<LocalStorage name="MyCustomLogs" cleanOnRoleRecycle="false" sizeInMB="10" />
</LocalResources>
When I add a TextWriterTraceListener
in my local Compute Emulator, it works:
<trace autoflush="true">
<listeners>
<add type="System.Diagnostics.TextWriterTraceListener" name="TextWriter"
initializeData="c:\trace.log" />
</listeners>
</trace>
However, this does not work on Azure. (I suspect permissions?)
I'm at a standstill at this point. No errors anywhere, but no logs either. There's no record of the Blob being created in my Blob Store.