Esempio n. 1
0
        private static void Initialize(ExDateTime serviceStartTime, string logFilePath, TimeSpan maxRetentionPeriond, ByteQuantifiedSize directorySizeQuota, ByteQuantifiedSize perFileSizeQuota, bool applyHourPrecision)
        {
            int registryInt;

            using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters"))
            {
                GLSLogger.Enabled = GLSLogger.GetRegistryBool(registryKey, "ProtocolLoggingEnabled", true);
                registryInt       = GLSLogger.GetRegistryInt(registryKey, "LogBufferSize", 65536);
            }
            if (GLSLogger.registryWatcher == null)
            {
                GLSLogger.registryWatcher = new RegistryWatcher("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters", false);
            }
            if (GLSLogger.timer == null)
            {
                GLSLogger.timer = new Timer(new TimerCallback(GLSLogger.UpdateConfigIfChanged), null, 0, 300000);
            }
            if (GLSLogger.Enabled)
            {
                GLSLogger.log = new Log(GLSLogger.logFilePrefix, new LogHeaderFormatter(GLSLogger.schema, LogHeaderCsvOption.CsvCompatible), "GLSLogs");
                GLSLogger.log.Configure(logFilePath, maxRetentionPeriond, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, registryInt, GLSLogger.defaultFlushInterval);
                AppDomain.CurrentDomain.ProcessExit += GLSLogger.CurrentDomain_ProcessExit;
            }
            GLSLogger.Initialized = true;
        }
Esempio n. 2
0
 private static void UpdateConfigIfChanged(object state)
 {
     if (GLSLogger.registryWatcher.IsChanged())
     {
         using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess\\Parameters"))
         {
             bool registryBool = GLSLogger.GetRegistryBool(registryKey, "ProtocolLoggingEnabled", true);
             if (registryBool != GLSLogger.Enabled)
             {
                 lock (GLSLogger.logLock)
                 {
                     GLSLogger.Initialized = false;
                     GLSLogger.Enabled     = registryBool;
                 }
             }
         }
     }
 }