public static async Task ProcessRequest(HttpContext context, ErrorLog errorLog, string elmahRoot) { const int pageSize = 15; var entries = new List <ErrorLogEntry>(pageSize); var log = errorLog; log.GetErrors(0, pageSize, entries); var response = context.Response; response.ContentType = "application/xml"; var title = string.Format(@"Error log of {0} on {1}", log.ApplicationName, Environment.MachineName); var link = $"{context.Request.Scheme}://{context.Request.Host}{elmahRoot}"; var baseUrl = new Uri(link.TrimEnd('/') + "/"); var items = from entry in entries let error = entry.Error select RssXml.Item( error.Message, "An error of type " + error.Type + " occurred. " + error.Message, error.Time, baseUrl + "detail?id=" + Uri.EscapeDataString(entry.Id)); var rss = RssXml.Rss(title, link, "Log of recent errors", items); await response.WriteAsync(XmlText.StripIllegalXmlCharacters(rss.ToString())); }
public static async Task ProcessRequest(HttpContext context, ErrorLog errorLog, string elmahRoot) { var log = errorLog; var request = context.Request; var response = context.Response; response.ContentType = "application/xml"; var title = string.Format(@"Daily digest of errors in {0} on {1}", log.ApplicationName, Environment.MachineName); var link = $"{context.Request.Scheme}://{context.Request.Host}{elmahRoot}"; var baseUrl = new Uri(link.TrimEnd('/') + "/"); var items = GetItems(log, baseUrl, 30, 30).Take(30); var rss = RssXml.Rss(title, link, "Daily digest of application errors", items); await context.Response.WriteAsync(XmlText.StripIllegalXmlCharacters(rss.ToString())); }