public List <AutoUpdaterMessage> FetchSynapseLogList() { string context = GetContext(nameof(FetchSynapseLogList)); try { SynapseServer.Logger.Debug(context); return(Log4netUtil.FetchLogList()); } catch (Exception ex) { SynapseServer.Logger.Error( Utilities.UnwindException(context, ex, asSingleLine: true)); throw; } }
public netHttp.HttpResponseMessage FetchSynapseLog(string name) { string context = GetContext(nameof(FetchSynapseLogList)); try { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name), $"Logfile name is required."); } string path = Log4netUtil.GetLogfilePath(name); if (!File.Exists(path)) { throw new FileNotFoundException($"Log [{name}] not found.", name); } FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); netHttp.HttpResponseMessage msg = new netHttp.HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new netHttp.StreamContent(stream) }; msg.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = name }; msg.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return(msg); } catch (Exception ex) { SynapseServer.Logger.Error( Utilities.UnwindException(context, ex, asSingleLine: true)); throw; } }