/// <summary> /// 功能:获取日志文件内容 /// </summary> /// <param name="strLogFileName">日志文件名称或路径</param> /// <returns>日志文件内容</returns> public static FeedBackResponse <string> GetLogFileContent(string strLogFileName) { FeedBackResponse <string> fbrReturn = new FeedBackResponse <string>(); string strFilePath = System.IO.Path.GetDirectoryName(strLogFileName); if (string.IsNullOrWhiteSpace(strFilePath)) { List <string> lstPath = SysLogHelper.GetLogPath(); if (lstPath.Count == 0) { fbrReturn.Message = "获取日志路径失败!"; } else { lstPath.ForEach(lp => { string strLogFilePath = System.IO.Path.Combine(lp, strLogFileName); if (FileHelper.IsFileExist(strLogFilePath)) { fbrReturn.ResultData = GetLogContent(strLogFilePath); return; } }); } } else { fbrReturn.ResultData = GetLogContent(strLogFileName); } return(fbrReturn); }
/// <summary> /// 功能:搜索日志文件列表 /// </summary> /// <param name="strSearchName">搜索名称</param> /// <returns>日志文件列表</returns> public static FeedBackResponse <List <string> > SearchLogFiles(string strSearchName) { FeedBackResponse <List <string> > fbrReturn = new FeedBackResponse <List <string> >(); List <string> lstReturn = new List <string>(); List <string> lstPath = SysLogHelper.GetLogPath(); lstPath.ForEach(lp => { lstReturn.AddRange(System.IO.Directory.GetFiles(lp, "*" + strSearchName + "*")); }); fbrReturn.ResultData = lstReturn; return(fbrReturn); }