document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private static void logException(Exception ex, string filePath)
  2. {
  3.     string timestamp = DateTime.Now.ToString();
  4.     StringBuilder sb = new StringBuilder();
  5.     int i = 1;
  6.     while (ex != null)
  7.     {
  8.         if (i == 1)
  9.         {
  10.             sb.AppendLine(String.Format("[{1}]:{0}Message:    {2}{0}Source:     {3}{0}StackTrace: {4}",
  11.         Environment.NewLine, timestamp, ex.Message, ex.Source, ex.StackTrace));
  12.         }
  13.         else
  14.         {
  15.             sb.AppendLine(String.Format("Inner exception:"));
  16.             sb.AppendLine(String.Format("{0}Message:    {2}{1}{0}Source:     {3}{1}{0}StackTrace: {4}",  
  17.         new String(\'\\t\', i), Environment.NewLine, ex.Message, ex.Source, ex.StackTrace));
  18.         }
  19.  
  20.         ex = ex.InnerException;
  21.         i++;
  22.     }
  23.  
  24.     using (StreamWriter sw = new StreamWriter(filePath, true))
  25.     {
  26.         sw.WriteLine(sb.ToString());
  27.     }
  28. }
');