Or other logs.

In my local environment following code worked:

 

using System;
using System.Diagnostics;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.Diagnostics.Management;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace MvcWebRole1
{
    public class WebRole : RoleEntryPoint
    {
        public override void Run()
        {
            SetLogging();
            base.Run();
        }
        public override bool OnStart()
        {
            return base.OnStart();
        }

        protected virtual void SetLogging()
        {
            if (RoleEnvironment.IsAvailable)
            {
                string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
                //CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=myAccountName;AccountKey=myAccountKey");
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

                RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);
                DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

                config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
                config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
                roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
            }
        }
    }
}

Part which is commented:

//CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=myAccountName;AccountKey=myAccountKey");

Is in use for the Azure, if you want to upload to Azure, then AccountName and AccountKey has to be changed, if anything from these two is wrong, Azure will not report a problem, but virtual machine will not be started.

Also, instead of

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

It can be:

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));

Also, in local environment, if WadLogsTable is not populated, then reset Azure storage emulator (you will delete all tables and data you have in local storage), and also restart computer, obviously some service has to be restarted, but I don't know which one exactly... and wait at least 3 minutes, while application is started (debugged).

Only TraceError will be logged, and it should be somewhere in controller, because in OnStart will not work.

---

Another solution is this code

 

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Diagnostics;
using Microsoft.WindowsAzure.Diagnostics.Management;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace MvcWebRole1
{
    public class WebRole : RoleEntryPoint
    {

        public override bool OnStart()
        {
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            // instantiate and add a new diagnostic monitor trace listener
            // before doing this, you should make sure no listeners are defined in your web.config or app.config
            var tempListener = new DiagnosticMonitorTraceListener();
            Trace.Listeners.Add(tempListener);

            // creates a diagnostic manager instance based on an azure storage account
            // before doing this, setup a storage account using the azure web portal
            string connectionStringName = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
            var storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(connectionStringName));
            var roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId,
            RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);

            // setup the basic logging configuration options
            // ScheduledTransferPeriod is how often the trace log is copied to the storage account tables
            // ScheduledTransferLogLevelFilter is the filter on the messages to copy
            // BufferQuotaInMB is how much space is available to the local buffer (when limit is reached, old data is purged)
            var config = roleInstanceDiagnosticManager.GetCurrentConfiguration();
            config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
            config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
            config.Logs.BufferQuotaInMB = 5;

            // setup the windows event log configuration options
            // adds the System and Application level windows event logs to the sources
            // other options are the same as the basic logging
            config.WindowsEventLog.DataSources.Add("System!*");
            config.WindowsEventLog.DataSources.Add("Application!*");
            config.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
            config.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
            roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
            return base.OnStart();
        }

    }
}

More details can be found here.

Lines of code:

            config.WindowsEventLog.DataSources.Add("System!*");
            config.WindowsEventLog.DataSources.Add("Application!*");

Will create Windows Event Logs, to create WADLogsTable I am not exactly sure which DataSource has to be added. This solution is using Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString, which can be found in ServiceConfiguration.Cloud.cscfg, or ServiceConfiguration.Local.cscfg, depending on which you need, local or cloud deployment.

Also, don't forget to set level of monitoring to verbose:

WADLogsTable

Cloud services -> Configure

---

Just to add my conclusion, actually both ways of creating WadLogsTable are working, and there is no really need for setting level of monitoring, only problem is that trace.Error has to be somewhere in controller (executed on some action), and we have to wait long enough (3 minutes for example)

---

To query WadLog table, using Visual Studio 2010, I can use query like:

PartitionKey ge '0635228657410000000' and Role eq 'MyRole' and Level le 3

Where number 0635228657410000000 is generated with this tool, that tool will generate number like:

635228656810000000, which means that I have to add additional 0 at beginning of that number

And Level is used to show only errors