private void LogTraceFailure(string traceString, Exception e) { TimeSpan timeSpan = TimeSpan.FromMinutes(10); try { lock (this.localSyncObject) { if (DateTime.UtcNow.Subtract(this.LastFailure) >= timeSpan) { this.LastFailure = DateTime.UtcNow; Microsoft.ServiceBus.Diagnostics.EventLogger eventLogger = new Microsoft.ServiceBus.Diagnostics.EventLogger(this.eventSourceName, this); if (e != null) { string[] strArrays = new string[] { traceString, e.ToString() }; eventLogger.LogEvent(TraceEventType.Error, EventLogCategory.Tracing, Microsoft.ServiceBus.Diagnostics.EventLogEventId.FailedToTraceEventWithException, false, strArrays); } else { string[] strArrays1 = new string[] { traceString }; eventLogger.LogEvent(TraceEventType.Error, EventLogCategory.Tracing, Microsoft.ServiceBus.Diagnostics.EventLogEventId.FailedToTraceEvent, false, strArrays1); } } } } catch { } }
internal DiagnosticTrace(TraceSourceKind sourceType, string traceSourceName, string eventSourceName) { this.traceSourceType = sourceType; this.TraceSourceName = traceSourceName; this.eventSourceName = eventSourceName; this.AppDomainFriendlyName = AppDomain.CurrentDomain.FriendlyName; try { this.CreateTraceSource(); AppDomain currentDomain = AppDomain.CurrentDomain; this.haveListeners = this.TraceSource.Listeners.Count > 0; this.tracingEnabled = this.HaveListeners; if (this.TracingEnabled) { currentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.UnhandledExceptionHandler); this.SetLevel(this.TraceSource.Switch.Level); currentDomain.DomainUnload += new EventHandler(this.ExitOrUnloadEventHandler); currentDomain.ProcessExit += new EventHandler(this.ExitOrUnloadEventHandler); } } catch (ConfigurationErrorsException configurationErrorsException) { throw; } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } Microsoft.ServiceBus.Diagnostics.EventLogger eventLogger = new Microsoft.ServiceBus.Diagnostics.EventLogger(this.eventSourceName, null); string[] str = new string[] { exception.ToString() }; eventLogger.LogEvent(TraceEventType.Error, EventLogCategory.Tracing, Microsoft.ServiceBus.Diagnostics.EventLogEventId.FailedToSetupTracing, false, str); } }