public static void StartFileLogging(string path, string dataMiningPath = null) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } TaskLogger.indentationLevel = 0; TaskLogger.logFilePath = path; TaskLogger.dataMiningLogFilePath = dataMiningPath; TaskLogger.ResumeFileLogging(); }
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; } }