protected void PublishMonitoringResult(int numberofAttemptsAfterLastSuccess, ExDateTime firstFailedSyncTimeAfterLastSuccess, ExDateTime lastFailedSyncTime) { TimeSpan t = lastFailedSyncTime - firstFailedSyncTimeAfterLastSuccess; if (numberofAttemptsAfterLastSuccess >= PublicFolderMailboxLogger.MinNumberOfFailedSyncAttemptsForAlert && t >= PublicFolderMailboxLogger.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.pfSession.MailboxGuid.ToString(); eventNotificationItem.StateAttribute2 = this.pfSession.MdbGuid.ToString(); eventNotificationItem.StateAttribute3 = ((this.pfSession.OrganizationId.OrganizationalUnit != null) ? this.pfSession.OrganizationId.OrganizationalUnit.Name.ToString() : string.Empty); if (this.LastError == null) { eventNotificationItem.Message = "No LastError but failing for at least this long: " + PublicFolderMailboxLogger.MinDurationOfSyncFailureForAlert; } else { eventNotificationItem.Message = PublicFolderMailboxLoggerBase.GetExceptionLogString(this.LastError, PublicFolderMailboxLoggerBase.ExceptionLogOption.All); } try { eventNotificationItem.Publish(false); } catch (UnauthorizedAccessException e) { this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", PublicFolderMailboxLoggerBase.GetExceptionLogString(e, PublicFolderMailboxLoggerBase.ExceptionLogOption.All))); } catch (EventLogNotFoundException e2) { this.LogEvent(LogEventType.Warning, string.Format("PublishMonitoringResult: Failed with exception {0}", PublicFolderMailboxLoggerBase.GetExceptionLogString(e2, PublicFolderMailboxLoggerBase.ExceptionLogOption.All))); } } }
public virtual void ReportError(string errorContextMessage, Exception syncException) { this.LogEvent(LogEventType.Error, string.Format(CultureInfo.InvariantCulture, "[ErrorContext:{0}] {1}", new object[] { errorContextMessage, PublicFolderMailboxLoggerBase.GetExceptionLogString(syncException, PublicFolderMailboxLoggerBase.ExceptionLogOption.All) })); }
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", PublicFolderMailboxLoggerBase.GetExceptionLogString(this.LastError, PublicFolderMailboxLoggerBase.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) { PublicFolderMailboxLoggerBase.LogOnServer(exception, this.logComponent, this.logSuffixName); } catch (StoragePermanentException exception2) { PublicFolderMailboxLoggerBase.LogOnServer(exception2, this.logComponent, this.logSuffixName); } return(false); }
internal static void LogOnServer(Exception exception, string logComponent, string logSuffixName) { PublicFolderMailboxLoggerBase.LogOnServer(PublicFolderMailboxLoggerBase.GetExceptionLogString(exception, PublicFolderMailboxLoggerBase.ExceptionLogOption.All), LogEventType.Error, logComponent, logSuffixName, null); }