Beispiel #1
0
        private void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriod, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision)
        {
            int registryInt;

            using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters"))
            {
                this.enabled = ServiceTopologyLog.GetRegistryBool(registryKey, "ServiceTopologyLoggingEnabled", false);
                registryInt  = ServiceTopologyLog.GetRegistryInt(registryKey, "LogBufferSize", 524288);
                int registryInt2 = ServiceTopologyLog.GetRegistryInt(registryKey, "FlushIntervalInMinutes", 15);
                if (registryInt2 > 0)
                {
                    ServiceTopologyLog.FlushInterval = TimeSpan.FromMinutes((double)registryInt2);
                }
            }
            if (this.registryWatcher == null)
            {
                this.registryWatcher = new RegistryWatcher("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters", false);
            }
            if (this.timer == null)
            {
                this.timer = new Timer(new TimerCallback(this.UpdateConfigIfChanged), null, 0, 300000);
            }
            this.log = new Log(ServiceTopologyLog.LogFilePrefix, new LogHeaderFormatter(ServiceTopologyLog.Schema, LogHeaderCsvOption.CsvCompatible), "ServiceTopologyLogs");
            this.log.Configure(logFilePath, maxRetentionPeriod, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, registryInt, ServiceTopologyLog.FlushInterval, LogFileRollOver.Hourly);
            AppDomain.CurrentDomain.ProcessExit += this.CurrentDomain_ProcessExit;
            this.initialized = true;
        }
Beispiel #2
0
 private void UpdateConfigIfChanged(object state)
 {
     if (this.registryWatcher.IsChanged())
     {
         using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters"))
         {
             bool registryBool = ServiceTopologyLog.GetRegistryBool(registryKey, "ServiceTopologyLoggingEnabled", false);
             if (registryBool != this.enabled)
             {
                 lock (this.logLock)
                 {
                     this.initialized = false;
                     this.enabled     = registryBool;
                 }
             }
         }
     }
 }