EntLib Logging in Azure Pt 2 – All is not what it seems

After confirming my environment was good I modified the sample code and added logging to the OnStart, I also added an OnRun with some logging and a simple while loop.

public override bool OnStart()
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>

var configuration = DiagnosticMonitor.GetDefaultInitialConfiguration();
configuration.Logs.BufferQuotaInMB = 4;
configuration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
configuration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
DiagnosticMonitor.Start(“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”, configuration);

EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(new FileConfigurationSource("web.config", false));

Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("OnStart " + DateTime.UtcNow.ToLongTimeString());

return base.OnStart();

public override void Run()
Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Run Start " + DateTime.UtcNow.ToLongTimeString());

while (true)
Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Run Loop " + DateTime.UtcNow.ToLongTimeString());


Initially the webrole wouldn’t start and then after re-reading the full IIS vs. core post I realised that the entlib couldn’t find its config file so I added

EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(new FileConfigurationSource(“web.config”, false));

I could then see some log entries (note the process name…)


But my onStart logging wasn’t working and when I looked at the timestamps on the log entries it felt like there were some missing. Time for some more reading…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.