Ejemplo n.º 1
0
 internal static void Append(string operation, string resultCode, long processingTime, string failure, string lookupKey, string partnerId, string ipAddress, string diagnosticHeader, string transactionId)
 {
     lock (MservProtocolLog.logLock)
     {
         if (!MservProtocolLog.Initialized)
         {
             MservProtocolLog.Initialize(ExDateTime.UtcNow, Path.Combine(MservProtocolLog.GetExchangeInstallPath(), "Logging\\Mserv\\"), MservProtocolLog.defaultMaxRetentionPeriod, MservProtocolLog.defaultDirectorySizeQuota, MservProtocolLog.defaultPerFileSizeQuota, true);
         }
     }
     if (MservProtocolLog.Enabled)
     {
         LogRowFormatter logRowFormatter = new LogRowFormatter(MservProtocolLog.schema);
         logRowFormatter[1]  = MservProtocolLog.GetNextSequenceNumber();
         logRowFormatter[2]  = Globals.ProcessName;
         logRowFormatter[4]  = Globals.ProcessAppName;
         logRowFormatter[3]  = Globals.ProcessId;
         logRowFormatter[5]  = operation;
         logRowFormatter[7]  = processingTime;
         logRowFormatter[6]  = resultCode;
         logRowFormatter[8]  = failure;
         logRowFormatter[9]  = lookupKey;
         logRowFormatter[10] = partnerId;
         logRowFormatter[11] = ipAddress;
         logRowFormatter[12] = diagnosticHeader;
         logRowFormatter[13] = transactionId;
         MservProtocolLog.log.Append(logRowFormatter, 0);
     }
 }
Ejemplo n.º 2
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 Mserv\\Parameters"))
            {
                MservProtocolLog.Enabled = MservProtocolLog.GetRegistryBool(registryKey, "ProtocolLoggingEnabled", true);
                registryInt = MservProtocolLog.GetRegistryInt(registryKey, "LogBufferSize", 65536);
            }
            if (MservProtocolLog.registryWatcher == null)
            {
                MservProtocolLog.registryWatcher = new RegistryWatcher("SYSTEM\\CurrentControlSet\\Services\\MSExchange Mserv\\Parameters", false);
            }
            if (MservProtocolLog.timer == null)
            {
                MservProtocolLog.timer = new Timer(new TimerCallback(MservProtocolLog.UpdateConfigIfChanged), null, 0, 300000);
            }
            if (MservProtocolLog.Enabled)
            {
                MservProtocolLog.log = new Log(MservProtocolLog.logFilePrefix, new LogHeaderFormatter(MservProtocolLog.schema, LogHeaderCsvOption.CsvCompatible), "MservLogs");
                MservProtocolLog.log.Configure(logFilePath, maxRetentionPeriond, (long)directorySizeQuota.ToBytes(), (long)perFileSizeQuota.ToBytes(), applyHourPrecision, registryInt, MservProtocolLog.defaultFlushInterval);
                AppDomain.CurrentDomain.ProcessExit += MservProtocolLog.CurrentDomain_ProcessExit;
            }
            MservProtocolLog.Initialized = true;
        }
Ejemplo n.º 3
0
 private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
 {
     lock (MservProtocolLog.logLock)
     {
         MservProtocolLog.Enabled     = false;
         MservProtocolLog.Initialized = false;
         MservProtocolLog.Shutdown();
     }
 }
Ejemplo n.º 4
0
 private static void UpdateConfigIfChanged(object state)
 {
     if (MservProtocolLog.registryWatcher.IsChanged())
     {
         using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\MSExchange Mserv\\Parameters"))
         {
             bool registryBool = MservProtocolLog.GetRegistryBool(registryKey, "ProtocolLoggingEnabled", true);
             if (registryBool != MservProtocolLog.Enabled)
             {
                 lock (MservProtocolLog.logLock)
                 {
                     MservProtocolLog.Initialized = false;
                     MservProtocolLog.Enabled     = registryBool;
                 }
             }
         }
     }
 }