/// <summary> /// Append the last 10K of the exception log to the report /// </summary> private void ExceptionLog() { _report.AppendLine("**********************************************************************************"); _report.AppendLine("Exception Log"); SafelyRun(() => { var nameFormat = MvcApplication.GetLogFileNameFormat(); var todayLogFileName = nameFormat.Replace("{Date}", DateTime.Now.ToString("yyyyMMdd")); SafelyReport("LogFileName: ", () => todayLogFileName); var chunkSize = 10000; var length = new FileInfo(todayLogFileName).Length; Report("Log File total length", length); var startingPoint = Math.Max(0, length - chunkSize); Report("Starting log dump from ", startingPoint); using (var logText = File.Open(todayLogFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { logText.Seek(startingPoint, SeekOrigin.Begin); var reader = new StreamReader(logText); _report.AppendLine(reader.ReadToEnd()); } }); }