Пример #1
0
 public static void LogException(string ProviderInternalName, string faultyAction, LdapcpLogging.Categories category, Exception ex)
 {
     try
     {
         string message = "[{0}] Unexpected error {1}: {2}: {3}, Callstack: {4}";
         if (ex is AggregateException)
         {
             var aggEx = ex as AggregateException;
             foreach (var innerEx in aggEx.InnerExceptions)
             {
                 if (innerEx.InnerException != null)
                 {
                     message = String.Format(message, ProviderInternalName, faultyAction, innerEx.InnerException.GetType().FullName, innerEx.InnerException.Message, innerEx.InnerException.StackTrace);
                 }
                 else
                 {
                     message = String.Format(message, ProviderInternalName, faultyAction, innerEx.GetType().FullName, innerEx.Message, innerEx.StackTrace);
                 }
                 WriteTrace(category, TraceSeverity.Unexpected, message);
             }
         }
         else
         {
             if (ex.InnerException != null)
             {
                 message = String.Format(message, ProviderInternalName, faultyAction, ex.InnerException.GetType().FullName, ex.InnerException.Message, ex.InnerException.StackTrace);
             }
             else
             {
                 message = String.Format(message, ProviderInternalName, faultyAction, ex.GetType().FullName, ex.Message, ex.StackTrace);
             }
             WriteTrace(category, TraceSeverity.Unexpected, message);
         }
     }
     catch
     {   // Don't want to do anything if logging goes wrong, just ignore and continue
     }
 }
Пример #2
0
 public static void Log(string message, TraceSeverity traceSeverity, EventSeverity eventSeverity, LdapcpLogging.Categories category)
 {
     try
     {
         WriteTrace(category, traceSeverity, message);
         //LdapcpLoggingService.WriteEvent(LdapcpLoggingService.Categories.LDAPCP, eventSeverity, message);
     }
     catch
     {   // Don't want to do anything if logging goes wrong, just ignore and continue
     }
 }