internal void Append(string callerFilePath, string memberName, int callerFileLine) { if (!this.initialized) { lock (this.logLock) { if (!this.initialized) { this.Initialize(ExDateTime.UtcNow, Path.Combine(ServiceTopologyLog.GetExchangeInstallPath(), "Logging\\ServiceTopology\\"), ServiceTopologyLog.DefaultMaxRetentionPeriod, ServiceTopologyLog.DefaultDirectorySizeQuota, ServiceTopologyLog.DefaultPerFileSizeQuota, true); } } } if (this.enabled) { LogRowFormatter logRowFormatter = new LogRowFormatter(ServiceTopologyLog.Schema); logRowFormatter[1] = this.GetNextSequenceNumber(); logRowFormatter[2] = Globals.ProcessName; logRowFormatter[3] = Globals.ProcessId; logRowFormatter[4] = string.Format("{0}: Method {1}: Line {2}", callerFilePath, memberName, callerFileLine); lock (this.logLock) { this.rows.Add(logRowFormatter); if (this.flush == null) { this.flush = new ServiceTopologyLog.FlushDelegate(this.FlushRows); this.flush.BeginInvoke(null, null); } } } }
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; }
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; } } } } }