/// <summary> /// 构造 /// </summary> /// <param name="logLevel"></param> /// <param name="filePath"></param> public RollingFileLogger(int logLevel, string filePath) : base(logLevel) { while (filePath.EndsWith("\\")) { filePath = filePath.Substring(0, filePath.Length - 1); } this.filePath = filePath; RollingFileAppender.CheckDirectory(FilePath); }
/// <summary> /// 处理当用户不输入文件名时 /// 按默认的文件名处理 /// </summary> /// <param name="fileName">文件名</param> /// <param name="fileType">文件类型</param> /// <returns></returns> private string PrepareFileName(string fileName, string fileType) { try{ if (fileName.Trim() == "") { fileName = filePath + @"\\" + fileType + RollingFileAppender.GetFileNameFromDate(); } else { fileName = filePath + "\\" + fileName; } RollingFileAppender.CheckDirectory(filePath); return(fileName); } catch (Exception) { return(""); } }