public void StartLogging() { if (!Directory.Exists(SetupLoggerImpl.setupLogDirectory)) { Directory.CreateDirectory(SetupLoggerImpl.setupLogDirectory); } string filename = Path.Combine(SetupLoggerImpl.setupLogDirectory, SetupLoggerImpl.setupLogFileNameForWatson); string filename2 = Path.Combine(SetupLoggerImpl.setupLogDirectory, "ExchangeSetup.msilog"); string dataMiningPath = null; if (DatacenterRegistry.IsMicrosoftHostedOnly()) { string text = "d:\\ExchangeSetupLogs"; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } dataMiningPath = Path.Combine(text, SetupLoggerImpl.setupLogFileName); } ExWatson.TryAddExtraFile(filename); ExWatson.TryAddExtraFile(filename2); try { TaskLogger.IsSetupLogging = true; TaskLogger.StartFileLogging(SetupLoggerImpl.setupLogFilePath, dataMiningPath); this.isLoggingStarted = true; } catch (IOException ex) { throw new SetupLogInitializeException(ex.Message, ex); } catch (UnauthorizedAccessException ex2) { throw new SetupLogInitializeException(ex2.Message, ex2); } this.Log(SetupLoggerImpl.AsterixLine); this.Log(Strings.SetupLogStarted); this.Log(SetupLoggerImpl.AsterixLine); this.Log(Strings.LocalTimeZone(TimeZoneInfo.Local.DisplayName)); this.Log(Strings.OSVersion(Environment.OSVersion.ToString())); try { this.LogAssemblyVersion(); } catch (FileVersionNotFoundException ex3) { throw new SetupLogInitializeException(ex3.Message, ex3); } this.LogUserName(); this.TaskStartTime = DateTime.UtcNow; }
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; } }