Ejemplo n.º 1
0
 /// <summary>
 /// Calls  Trace Listener TraceData().
 /// For client use.
 /// <remarks>EventType = Error</remarks>
 /// </summary>
 public void LogException(Exception exception)
 {
     // Avoid re throw the same exception
     if (_lastException != exception)
     {
         try
         {
             /// Logs with the  Trace Listener
             _traceListener.TraceData(new TraceEventCache(), "", TraceEventType.Error, 0, exception);
         }
         catch (Exception ex)
         {
             // Logs logging exception too
             LogExceptionToFileSystem(ex.ToString());
         }
         finally
         {
             _lastException = exception;
         }
     }
 }
Ejemplo n.º 2
0
        public void Should_LogExceptions_WhenTheyContainAnInnerException()
        {
            var trace = new TraceListener("events-live,logs-live,azuresync");

            try
            {
                try
                {
                    throw new Exception("tatatata");
                }
                catch (Exception inner)
                {
                    throw new Exception("blah", inner);
                }
            }
            catch (Exception exp)
            {
                trace.TraceData(null, "mimimim", System.Diagnostics.TraceEventType.Error, 0, "shix", exp);
            }
        }
Ejemplo n.º 3
0
 public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data)
 => Lock(() => listener.TraceData(eventCache, source, eventType, id, data));