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

            //if we don't do this, Azure tracelistener only runs in the cloud, and we can't run this app standalone.
            Dictionary <string, SourceLevels> traceLevelMap = new Dictionary <string, SourceLevels>()
            {
                { "All", SourceLevels.All },
                { "Critical", SourceLevels.Critical },
                { "Error", SourceLevels.Error },
                { "Warning", SourceLevels.Warning },
                { "Information", SourceLevels.Information },
                { "ActivityTracing", SourceLevels.ActivityTracing },
                { "Verbose", SourceLevels.Verbose },
                { "Off", SourceLevels.Off }
            };

            if (RoleEnvironment.IsAvailable)
            {
                string       cloudTraceLevel = CloudConfigurationManager.GetSetting("cloudTraceLevel");
                SourceLevels sl = traceLevelMap.ContainsKey(cloudTraceLevel) ? traceLevelMap[cloudTraceLevel] : SourceLevels.Error;

                Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener tr =
                    new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener();
                tr.Filter = new EventTypeFilter(sl);

                Trace.Listeners.Add(tr);
                Trace.AutoFlush = true;
            }

            return(base.OnStart());
        }
コード例 #2
0
ファイル: WebRole.cs プロジェクト: laurikoobas/Azure
        public override bool OnStart()
        {
            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            //if we don't do this, Azure tracelistener only runs in the cloud, and we can't run this app standalone.
            Dictionary<string, SourceLevels> traceLevelMap = new Dictionary<string, SourceLevels>()
            {
                {"All", SourceLevels.All},
                {"Critical", SourceLevels.Critical},
                {"Error", SourceLevels.Error},
                {"Warning", SourceLevels.Warning},
                {"Information", SourceLevels.Information},
                {"ActivityTracing", SourceLevels.ActivityTracing},
                {"Verbose", SourceLevels.Verbose},
                {"Off", SourceLevels.Off}
            };
            if (RoleEnvironment.IsAvailable)
            {
                string cloudTraceLevel = CloudConfigurationManager.GetSetting("cloudTraceLevel");
                SourceLevels sl = traceLevelMap.ContainsKey(cloudTraceLevel) ? traceLevelMap[cloudTraceLevel] : SourceLevels.Error;

                Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener tr =
                    new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener();
                tr.Filter = new EventTypeFilter(sl);

                Trace.Listeners.Add(tr);
                Trace.AutoFlush = true;
            }

            return base.OnStart();
        }
コード例 #3
0
ファイル: WebRole.cs プロジェクト: al-main/CloudyBank
        public override bool OnStart()
        {
            try
            {
                DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
                //diagConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
                diagConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
                diagConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

                DiagnosticMonitor.Start("DataConnectionString", diagConfig);

                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
                RoleEnvironment.Changing += RoleEnvironmentChanging;

                // This code sets up a handler to update CloudStorageAccount instances when their corresponding
                // configuration settings change in the service configuration file.

                // This code sets up a handler to update CloudStorageAccount instances when their corresponding
                // configuration settings change in the service configuration file.
                CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
                {
                    // Provide the configSetter with the initial value
                    configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

                    RoleEnvironment.Changed += (s, arg) =>
                    {
                        if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
                          .Any((change) => (change.ConfigurationSettingName == configName)))
                        {
                            // The corresponding configuration setting has changed, propagate the value
                            if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                            {
                                // In this case, the change to the storage account credentials in the
                                // service configuration is significant enough that the role needs to be
                                // recycled in order to use the latest settings. (for example, the
                                // endpoint has changed)
                                RoleEnvironment.RequestRecycle();
                            }
                        }
                    };
                });

                var azureTraceListener = new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener();

                Trace.Listeners.Add(azureTraceListener);
            }
            catch (Exception)
            {

            }
            return base.OnStart();
        }
コード例 #4
0
ファイル: WebRole.cs プロジェクト: firebitsbr/CloudyBank
        public override bool OnStart()
        {
            try
            {
                DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
                //diagConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
                diagConfig.Logs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1);
                diagConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

                DiagnosticMonitor.Start("DataConnectionString", diagConfig);

                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
                RoleEnvironment.Changing += RoleEnvironmentChanging;

                // This code sets up a handler to update CloudStorageAccount instances when their corresponding
                // configuration settings change in the service configuration file.

                // This code sets up a handler to update CloudStorageAccount instances when their corresponding
                // configuration settings change in the service configuration file.
                CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
                {
                    // Provide the configSetter with the initial value
                    configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

                    RoleEnvironment.Changed += (s, arg) =>
                    {
                        if (arg.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                            .Any((change) => (change.ConfigurationSettingName == configName)))
                        {
                            // The corresponding configuration setting has changed, propagate the value
                            if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                            {
                                // In this case, the change to the storage account credentials in the
                                // service configuration is significant enough that the role needs to be
                                // recycled in order to use the latest settings. (for example, the
                                // endpoint has changed)
                                RoleEnvironment.RequestRecycle();
                            }
                        }
                    };
                });

                var azureTraceListener = new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener();

                Trace.Listeners.Add(azureTraceListener);
            }
            catch (Exception)
            {
            }
            return(base.OnStart());
        }