public static void LogError(Exception e) { while (e != null) { LocalizedException ex = e as LocalizedException; string message; if (ex != null && TaskLogger.FormatProvider != null) { IFormatProvider formatProvider = ex.FormatProvider; ex.FormatProvider = TaskLogger.FormatProvider; message = ex.Message; ex.FormatProvider = formatProvider; } else { message = e.Message; } ExTraceGlobals.ErrorTracer.TraceError <LocalizedString, string, string>(0L, "{0}{1}\n{2}", Strings.LogErrorPrefix, message, e.StackTrace); if (TaskLogger.fileLoggingEnabled) { TaskLogger.LogErrorString(message); } e = e.InnerException; } }
public static void SendWatsonReport(Exception e, string taskName, PropertyBag boundParameters) { TaskLogger.StopFileLogging(); bool flag = true; try { string sourceFileName = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, ConfigurationContext.Setup.SetupLogFileName); string text = Path.Combine(ConfigurationContext.Setup.SetupLoggingPath, ConfigurationContext.Setup.SetupLogFileNameForWatson); File.Copy(sourceFileName, text, true); int num = 0; while (!ExWatson.TryAddExtraFile(text) && num < 10) { Thread.Sleep(100); num++; } } catch (FileNotFoundException) { } catch (DirectoryNotFoundException) { } catch (IOException) { flag = false; if (TaskLogger.IsFileLoggingEnabled) { TaskLogger.LogErrorString(Strings.ExchangeSetupCannotCopyWatson(ConfigurationContext.Setup.SetupLogFileName, ConfigurationContext.Setup.SetupLogFileNameForWatson)); } } if (flag) { if (!string.IsNullOrEmpty(taskName)) { ExWatson.AddExtraData("Task Name: " + taskName); } if (boundParameters != null) { StringBuilder stringBuilder = new StringBuilder("Parameters:\n"); foreach (object obj in boundParameters) { DictionaryEntry dictionaryEntry = (DictionaryEntry)obj; if (dictionaryEntry.Value is IList) { stringBuilder.AppendLine(string.Format("{0}:{1}", dictionaryEntry.Key, MultiValuedPropertyBase.FormatMultiValuedProperty(dictionaryEntry.Value as IList))); } else { stringBuilder.AppendLine(string.Format("{0}:'{1}'", dictionaryEntry.Key, (dictionaryEntry.Value == null) ? "<null>" : dictionaryEntry.Value.ToString())); } } ExWatson.AddExtraData(stringBuilder.ToString()); } ExWatson.SendReport(e, ReportOptions.DoNotFreezeThreads, null); } try { TaskLogger.ResumeFileLogging(); } catch (IOException) { if (TaskLogger.IsFileLoggingEnabled) { TaskLogger.LogErrorString(Strings.ExchangeSetupCannotResumeLog(ConfigurationContext.Setup.SetupLogFileName)); } throw; } }