title: DiagnosticMonitorTraceListener not working in Azure
body: <p>I've got an app that I've deployed with Azure, and I am trying to get plain vanilla Tracing working</p>
  
  <p>I've gone through all of these articles: 
  <a href="https://stackoverflow.com/search?q=diagnosticmonitortracelistener">https://stackoverflow.com/search?q=diagnosticmonitortracelistener</a></p>
  
  <p>Here's my role entry point:</p>
  
  <pre><code>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();
      }
  }
  </code></pre>
  
  <p>Also put the trace listener in global.asax.cs:</p>
  
  <pre><code>        if (RoleEnvironment.IsAvailable) {
              Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
              Trace.AutoFlush = true;
          }
  </code></pre>
  
  <p>I've also tried just pasting it directly into web.config</p>
  
  <pre><code> &lt;trace&gt;
       &lt;add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, 
              Microsoft.WindowsAzure.Diagnostics, 
              Version=1.8.0.0, 
              Culture=neutral, 
              PublicKeyToken=31bf3856ad364e35"
              name="AzureDiagnostics"&gt;
              &lt;filter type="" /&gt;
  &lt;/add&gt;
  </code></pre>
  
  <p>This directory gets created in my Azure VM
  <code>C:\Resources\Directory\d63aeab4198d458a9c0b1d0f818e4054.CorpQna.Web.MyCustomLogs</code></p>
  
  <p>This is in my <code>ServiceDefinition.csdef</code> file:</p>
  
  <pre><code>&lt;LocalResources&gt;
    &lt;LocalStorage name="MyCustomLogs" cleanOnRoleRecycle="false" sizeInMB="10" /&gt;
  &lt;/LocalResources&gt;
  </code></pre>
  
  <p>When I add a <code>TextWriterTraceListener</code> in my local Compute Emulator, it works:</p>
  
  <pre><code>&lt;trace autoflush="true"&gt;
    &lt;listeners&gt;
                      &lt;add type="System.Diagnostics.TextWriterTraceListener" name="TextWriter"
                               initializeData="c:\trace.log" /&gt;
    &lt;/listeners&gt;
  &lt;/trace&gt;
  </code></pre>
  
  <p>However, this does not work on Azure.  (I suspect permissions?)</p>
  
  <p>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.  </p>