Beispiel #1
0
 public static void CreateLog(string path, string logContent)
 {
     if (string.IsNullOrEmpty(path))
     {
         throw new ArgumentNullException("path");
     }
     if (string.IsNullOrEmpty(logContent))
     {
         throw new ArgumentNullException("logContent");
     }
     try
     {
         FileExcute.FolderCreate(PathInfo.GetErrorDir);
         FileExcute.FolderCreate(PathInfo.GetSysLogDir);
         if (!logContent.EndsWith("\r\n"))
         {
             logContent = string.Format("{0}{1}{2}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss,"), logContent, Separated);
         }
         FileExcute.FileAdd(path, logContent);
     }
     catch (Exception ex)
     {
         FileExcute.FileAdd(PathInfo.GetErrorDir + "logerror.log", ex.ToString());
         throw ex;
     }
 }
Beispiel #2
0
        public static IList <string> GetLogString(LogType logType, DateTime date, string EmailAddress)
        {
            IList <string> retList = new List <string>();

            switch (logType)
            {
            case LogType.SysLog:
                _GetLogString(retList, FileExcute.ReadFile(string.Format("{0}{1}{3}", PathInfo.GetSysLogDir, date.ToString("yyyy-MM-dd"), ".log")));
                break;

            case LogType.UserErrorLog:
                _GetLogString(retList, FileExcute.ReadFile(string.Format("{0}{1}_{2}{3}", PathInfo.GetUserErrorLogDir(EmailAddress), EmailAddress, date.ToString("yyyy-MM-dd"), ".log")));
                break;

            case LogType.UserLog:
                _GetLogString(retList, FileExcute.ReadFile(string.Format("{0}{1}_{2}{3}", PathInfo.GetUserLogDir(EmailAddress), EmailAddress, date.ToString("yyyy-MM-dd"), ".log")));
                break;
            }
            return(retList);
        }