示例#1
0
        private void LogTraceFailure(string traceString, Exception exception)
        {
            TimeSpan span = TimeSpan.FromMinutes(10.0);

            try
            {
                lock (this.thisLock)
                {
                    if (DateTime.UtcNow.Subtract(this.LastFailure) >= span)
                    {
                        this.LastFailure = DateTime.UtcNow;
                        EventLogger logger = EventLogger.UnsafeCreateEventLogger(this.eventSourceName, this);
                        if (exception == null)
                        {
                            logger.UnsafeLogEvent(TraceEventType.Error, 4, 0xc0010068, false, new string[] { traceString });
                        }
                        else
                        {
                            logger.UnsafeLogEvent(TraceEventType.Error, 4, 0xc0010069, false, new string[] { traceString, exception.ToString() });
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                if (Fx.IsFatal(exception2))
                {
                    throw;
                }
            }
        }
示例#2
0
        protected void LogTraceFailure(string traceString, Exception exception)
        {
            TimeSpan timeSpan = TimeSpan.FromMinutes(10);

            try
            {
                lock (this.thisLock)
                {
                    DateTime utcNow = DateTime.UtcNow;
                    if (utcNow.Subtract(this.LastFailure) >= timeSpan)
                    {
                        this.LastFailure = DateTime.UtcNow;
                        EventLogger eventLogger = EventLogger.UnsafeCreateEventLogger(this.eventSourceName, this);
                        if (exception != null)
                        {
                            string[] str = new string[2];
                            str[0] = traceString;
                            str[1] = exception.ToString();
                            eventLogger.UnsafeLogEvent(TraceEventType.Error, 4, -1073676183, false, str);
                        }
                        else
                        {
                            string[] strArrays = new string[1];
                            strArrays[0] = traceString;
                            eventLogger.UnsafeLogEvent(TraceEventType.Error, 4, -1073676184, false, strArrays);
                        }
                    }
                }
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                if (Fx.IsFatal(exception1))
                {
                    throw;
                }
            }
        }
示例#3
0
        protected void LogTraceFailure(string traceString, Exception exception)
        {
            const int FailureBlackoutDuration = 10;
            TimeSpan  FailureBlackout         = TimeSpan.FromMinutes(FailureBlackoutDuration);

            try
            {
                lock (this.thisLock)
                {
                    if (DateTime.UtcNow.Subtract(this.LastFailure) >= FailureBlackout)
                    {
                        this.LastFailure = DateTime.UtcNow;
#pragma warning disable 618
                        EventLogger logger = EventLogger.UnsafeCreateEventLogger(this.eventSourceName, this);
#pragma warning restore 618
                        if (exception == null)
                        {
                            logger.UnsafeLogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToTraceEvent, false,
                                                  traceString);
                        }
                        else
                        {
                            logger.UnsafeLogEvent(TraceEventType.Error, TracingEventLogCategory, (uint)System.Runtime.Diagnostics.EventLogEventId.FailedToTraceEventWithException, false,
                                                  traceString, exception.ToString());
                        }
                    }
                }
            }
            catch (Exception eventLoggerException)
            {
                if (Fx.IsFatal(eventLoggerException))
                {
                    throw;
                }
            }
        }