3

I have a doubt with Azure Trace Logs. I have a Worker Role and I want to log certain events,

When we deploy the application locally we can read the Trace using Cerebrata Cerebrata Cloud Storage. But when we deploy to staying or production we can't. We are using the same Storage accounts.

Worker Code:

public override bool OnStart()
{
        // Set the maximum number of concurrent connections
        ServicePointManager.DefaultConnectionLimit = 12;

        DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();
        diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
        diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
        CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
        DiagnosticMonitor diagnosticMonitor = DiagnosticMonitor.Start(cloudStorageAccount, diagnosticMonitorConfiguration);
        return base.OnStart();
    }

     public override void Run()
    {
        // This is a sample worker implementation. Replace with your logic.
        Trace.WriteLine("UpdateWorker entry point called", "Information");

        while (true)
        {
            Thread.Sleep(5000);
            Trace.WriteLine("Working", "Information" + DateTime.Now);
        }
    }

App.config

        <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <system.diagnostics>
          <trace>
            <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>
          </trace>
        </system.diagnostics>
      </configuration>

Where should we look? Is something wrong with this code?

Thanks!

Ronald Wildenberg
  • 31,634
  • 14
  • 90
  • 133
  • 1
    Try out DbgView.exe utility http://technet.microsoft.com/en-us/sysinternals/bb896647 – sll Aug 15 '11 at 20:05
  • 1
    Everything looks about right. Are you sure you changed the connection string to something starting with https and not "UseDevelopmentStorage=true" – dunnry Aug 15 '11 at 20:57
  • 1
    There's a useful MSDN article about Azure logging here: http://msdn.microsoft.com/en-us/magazine/ff714589.aspx – dumbledad Jun 24 '12 at 14:06

2 Answers2

4

I think the problem is on the line with

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;

You are referencing the local development storage on your computer, which will not be available when running in the cloud. Use a proper connection string to Azure Storage and use that for writing the logs to.

Vidar Kongsli
  • 826
  • 2
  • 9
  • 20
0

May be you forgot to add the Azure Storage connection string “ServiceConfiguration.cscfg” file

<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=<Storage Account Name>;AccountKey=<Storage Account Key>" />
</ConfigurationSettings>