private void Configure() { //this fixes a bug in .net 4 that will be fixed in sp1 using (CloudEnvironment.EnsureSafeHttpContext()) { foreach (var item in config.RegisteredAssemblies) { RegisterAssembly(item); } foreach (var item in config.RegisteredSubscribers) { Subscribe(item); } } }
private void StartDiagnosticMonitor() { if (CloudEnvironment.IsAvailable) { using (CloudEnvironment.EnsureSafeHttpContext()) { var storageAccount = ConfigurationManager.AppSettings[CommonConsts.ConfigSettingStorageAccount]; var storageKey = ConfigurationManager.AppSettings[CommonConsts.ConfigSettingStorageAccountKey]; var diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration(); var diagnosticStorage = new CloudStorageAccount(new StorageCredentialsAccountAndKey(storageAccount, storageKey), true); // Configure the scheduled transfer period for all logs. diagnosticConfig.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1); diagnosticConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(10); // Configure the logs levels for scheduled transfers. diagnosticConfig.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error; diagnosticConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined; this.diagnosticMonitor = DiagnosticMonitor.Start(diagnosticStorage, diagnosticConfig); } } }