title: Windows Azure Console for Worker Role Cloud Service
body: <p>I have a worker role cloud service that I have recently developed on my local machine.  The service exposes a WCF interface that receives a file as a byte array, recompiles the file, converts it to the appropriate format, then stores it in Azure Storage.  I managed to get everything working using the Azure Compute Emulator on my machine and published the service to Azure and... nothing.  Running it on my machine again, it works as expected.  When I was working on it on my computer, the Azure Compute Emulator's console output was essential in getting the application running.  </p>
  
  <p>Is there a similar functionality that can be tapped into on the Cloud Service via RDP?  Such as starting/restarting the role at the command prompt or in power shell?  If not, what is the best way to debug/log what the worker role is doing (without using Intellitrace)?  I have diagnostics enabled in the project, but it doesn't seem to be giving me the same level of detail as the Computer Emulator console.  I've rerun the role and corresponding .NET application again on localhost and was unable to find any possible errors in the console.</p>
  
  <p><strong>Edit: The Next Best Thing</strong></p>
  
  <p>Falling back to manual logging, I implemented a class that would feed text files into my Azure Storage account.  Here's the code:</p>
  
  <pre><code>public class EventLogger
  {
      public static void Log(string message)
      {
          CloudBlobContainer cbc;
          cbc = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("StorageClientAccount"))
                     .CreateCloudBlobClient()
                     .GetContainerReference("errors");
          cbc.CreateIfNotExist();
          cbc.GetBlobReference(string.Format("event-{0}-{1}.txt", RoleEnvironment.CurrentRoleInstance.Id, DateTime.UtcNow.Ticks)).UploadText(message);
      }
  
  }
  </code></pre>
  
  <p>Calling ErrorLogger.Log() will create a new text file and record whatever message you put in there.  I found an example in the answer below.</p>