示例#1
0
        protected void PublishMonitoringResult(int numberofAttemptsAfterLastSuccess, ExDateTime firstFailedSyncTimeAfterLastSuccess, ExDateTime lastFailedSyncTime)
        {
            TimeSpan t = lastFailedSyncTime - firstFailedSyncTimeAfterLastSuccess;

            if (numberofAttemptsAfterLastSuccess >= FolderTaskLogger.MinNumberOfFailedSyncAttemptsForAlert && t >= FolderTaskLogger.MinDurationOfSyncFailureForAlert)
            {
                string name      = ExchangeComponent.PublicFolders.Name;
                string component = "PublicFolderMailboxSync";
                string empty     = string.Empty;
                EventNotificationItem eventNotificationItem = new EventNotificationItem(name, component, empty, ResultSeverityLevel.Error);
                eventNotificationItem.StateAttribute1 = this.storeSession.MailboxGuid.ToString();
                eventNotificationItem.StateAttribute2 = this.storeSession.MdbGuid.ToString();
                eventNotificationItem.StateAttribute3 = ((this.storeSession.OrganizationId != null && this.storeSession.OrganizationId.OrganizationalUnit != null) ? this.storeSession.OrganizationId.OrganizationalUnit.Name.ToString() : string.Empty);
                if (this.LastError == null)
                {
                    eventNotificationItem.Message = "No LastError but failing for at least this long: " + FolderTaskLogger.MinDurationOfSyncFailureForAlert;
                }
                else
                {
                    eventNotificationItem.Message = FolderTaskLoggerBase.GetExceptionLogString(this.LastError, FolderTaskLoggerBase.ExceptionLogOption.All);
                }
                try
                {
                    eventNotificationItem.Publish(false);
                }
                catch (UnauthorizedAccessException exception)
                {
                    this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", FolderTaskLoggerBase.GetExceptionLogString(exception, FolderTaskLoggerBase.ExceptionLogOption.All)));
                }
                catch (EventLogNotFoundException exception2)
                {
                    this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", FolderTaskLoggerBase.GetExceptionLogString(exception2, FolderTaskLoggerBase.ExceptionLogOption.All)));
                }
            }
        }
示例#2
0
 public virtual void ReportError(string errorContextMessage, Exception syncException)
 {
     this.LogEvent(LogEventType.Error, string.Format(CultureInfo.InvariantCulture, "[ErrorContext:{0}] {1}", new object[]
     {
         errorContextMessage,
         FolderTaskLoggerBase.GetExceptionLogString(syncException, FolderTaskLoggerBase.ExceptionLogOption.All)
     }));
 }
示例#3
0
        internal static void LogOnServer(string data, LogEventType eventType, string logComponent, string logSuffixName, FolderTaskLoggerBase.LogType logType, Guid?correlationId = null)
        {
            Log             log             = FolderTaskLoggerBase.InitializeServerLogging(logComponent, logSuffixName, logType);
            LogRowFormatter logRowFormatter = new LogRowFormatter(FolderTaskLoggerBase.GetLogSchema(logType));

            logRowFormatter[2] = eventType;
            logRowFormatter[5] = data;
            if (correlationId != null)
            {
                logRowFormatter[7] = correlationId;
            }
            log.Append(logRowFormatter, 0);
        }
示例#4
0
 public bool TrySave()
 {
     try
     {
         this.LogFinalFoldersStats();
         if (this.LastError == null)
         {
             this.SetSyncMetadataValue("NumberofAttemptsAfterLastSuccess", 0);
             this.SetSyncMetadataValue("FirstFailedSyncTimeAfterLastSuccess", null);
             this.LogEvent(LogEventType.Success, "Diagnostics for monitoring is successfully completed");
             this.SetSyncMetadataValue("LastSuccessfulSyncTime", ExDateTime.UtcNow);
         }
         else
         {
             this.SetSyncMetadataValue("LastSyncFailure", FolderTaskLoggerBase.GetExceptionLogString(this.LastError, FolderTaskLoggerBase.ExceptionLogOption.All));
             int num;
             this.TryGetSyncMetadataValue <int>("NumberofAttemptsAfterLastSuccess", out num);
             num++;
             this.SetSyncMetadataValue("NumberofAttemptsAfterLastSuccess", num);
             this.LogEvent(LogEventType.Error, "Diagnostics for monitoring is failed");
             ExDateTime utcNow = ExDateTime.UtcNow;
             this.SetSyncMetadataValue("LastFailedSyncTime", utcNow);
             ExDateTime exDateTime = default(ExDateTime);
             this.TryGetSyncMetadataValue <ExDateTime>("FirstFailedSyncTimeAfterLastSuccess", out exDateTime);
             if (num == 1 || exDateTime == default(ExDateTime))
             {
                 exDateTime = utcNow;
                 this.SetSyncMetadataValue("FirstFailedSyncTimeAfterLastSuccess", exDateTime);
             }
             this.PublishMonitoringResult(num, exDateTime, utcNow);
         }
         this.gZipLoggingStream.Dispose();
         this.gZipLoggingStream = null;
         this.loggingStream.Dispose();
         this.loggingStream = null;
         this.diagnosticsMetadata.Save();
         this.lastCycleLogMetadata.Save();
         return(true);
     }
     catch (StorageTransientException exception)
     {
         FolderTaskLoggerBase.LogOnServer(exception, this.logComponent, this.logSuffixName);
     }
     catch (StoragePermanentException exception2)
     {
         FolderTaskLoggerBase.LogOnServer(exception2, this.logComponent, this.logSuffixName);
     }
     return(false);
 }
示例#5
0
 private static Log InitializeServerLogging(string logComponent, string logSuffixName, FolderTaskLoggerBase.LogType logType)
 {
     if (!FolderTaskLoggerBase.initializedLogs.ContainsKey(logSuffixName))
     {
         lock (FolderTaskLoggerBase.initializeLockObject)
         {
             if (!FolderTaskLoggerBase.initializedLogs.ContainsKey(logSuffixName))
             {
                 Log log = new Log(FolderTaskLoggerBase.GetLogFileName(logSuffixName), new LogHeaderFormatter(FolderTaskLoggerBase.GetLogSchema(logType)), logComponent);
                 log.Configure(Path.Combine(ExchangeSetupContext.InstallPath, FolderTaskLoggerBase.GetLogPath(logType)), FolderTaskLoggerBase.LogMaxAge, 262144000L, 10485760L);
                 FolderTaskLoggerBase.initializedLogs.Add(logSuffixName, log);
             }
         }
     }
     return(FolderTaskLoggerBase.initializedLogs[logSuffixName]);
 }
示例#6
0
        public virtual LogRowFormatter LogEvent(LogEventType eventType, string data, FolderTaskLoggerBase.LogType logType)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentNullException("data");
            }
            Log             log             = FolderTaskLoggerBase.InitializeServerLogging(this.logComponent, this.logSuffixName, logType);
            LogRowFormatter logRowFormatter = new LogRowFormatter(FolderTaskLoggerBase.GetLogSchema(logType));

            logRowFormatter[2] = eventType;
            logRowFormatter[3] = this.organizationId.ToString();
            logRowFormatter[4] = this.MailboxGuid.ToString();
            logRowFormatter[7] = this.CorrelationId.ToString();
            logRowFormatter[5] = data;
            log.Append(logRowFormatter, 0);
            return(logRowFormatter);
        }
示例#7
0
 internal static void LogOnServer(Exception exception, string logComponent, string logSuffixName)
 {
     FolderTaskLoggerBase.LogOnServer(FolderTaskLoggerBase.GetExceptionLogString(exception, FolderTaskLoggerBase.ExceptionLogOption.All), LogEventType.Error, logComponent, logSuffixName, FolderTaskLoggerBase.LogType.Folder, null);
 }