/// <summary> /// /// </summary> /// <param name="Mode"></param> /// <param name="Context"></param> /// <param name="Message"></param> public void WriteLog(Mode.LogMode Mode, HttpContext Context, string Message) { if (this.MyLog != null) { this.MyLog.WriteLog(Mode, string.Format("[{0}] {1}", Context.GetClientIPv4(), Message)); } }
/// <summary> /// 寫入成 Log /// </summary> /// <param name="Mode"></param> /// <param name="Message">Log 訊息</param> private void WriteLog(Mode.LogMode Mode, string Message) { if (this._Log != null) { this._Log.WriteLog(Mode, Message); } }
/// <summary> /// 寫入成 Log /// </summary> /// <param name="Mode"></param> /// <param name="Message">Log 訊息</param> public void WriteLog(Mode.LogMode Mode, string Message) { if (MyLog != null) { MyLog.WriteLog(Mode, string.Format("[{0}] {1}", IPv4, Message)); } }
/// <summary> /// 寫入成 Log /// </summary> /// <param name="MessageType">Log 型態</param> /// <param name="AfterFileName">新的 Log 檔案名稱</param> /// <param name="Message">內容</param> /// <param name="DateTimeFormat">日期格式</param> /// <param name="Append">是否以覆加資料至該檔案方式寫入</param> public void WriteLog(Mode.LogMode MessageType, string AfterFileName, string Message, string DateTimeFormat, bool Append) { int type = (int)MessageType; string message_Type = "INFO "; if (type == 2) { message_Type = "DEBUG"; } else if (type == 3) { message_Type = "ERROR"; } if (this.Level > 1) { if (this.Level == 2 && type == 1) { return; } else if (this.Level == 3 && type != 3) { return; } } if (this.DirectoryPath == null || this.DirectoryPath.Length == 0) { return; } if (!System.IO.Directory.Exists(this.DirectoryPath)) { System.IO.Directory.CreateDirectory(this.DirectoryPath); } try { string dtString = DateTimeFormat != null && DateTimeFormat.Length > 0 ? "_" + DateTime.Now.ToString(DateTimeFormat) : string.Empty; string fileName = AfterFileName == null || AfterFileName.Length == 0 ? this.FileName + dtString : AfterFileName; string filePath = Path.Combine(this.DirectoryPath, string.Format("{0}.log", fileName)); if (!System.IO.File.Exists(filePath)) { using (FileStream fs = System.IO.File.Create(filePath)) { fs.Flush(); fs.Close(); } } using (StreamWriter sw = new StreamWriter(filePath, Append, this._LogEncoding)) { sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss,fff", CultureInfo.InvariantCulture) + " [" + message_Type + "] " + " " + Message); sw.Flush(); } this.Backup(filePath, this.MaxSize); } catch { } }
/// <summary> /// /// </summary> /// <param name="Mode"></param> /// <param name="Message"></param> public void WriteLog(Mode.LogMode Mode, string Message) { this.Log.WriteLog(Mode, Message); }
/// <summary> /// /// </summary> /// <param name="Mode"></param> /// <param name="Context"></param> /// <param name="Message"></param> public void WritePDFUploadLog(Mode.LogMode Mode, HttpContext Context, string Message) { this.PDFUploadLog.WriteLog(Mode, string.Format("[{0}] {1}", Context.GetClientIPv4(), Message)); }
/// <summary> /// 寫入成 Log (自訂檔案名稱) /// </summary> /// <param name="MessageType">Log 型態</param> /// <param name="AfterFileName">新的 Log 檔案名稱</param> /// <param name="Message">內容</param> public void WriteLog(Mode.LogMode MessageType, string AfterFileName, string Message) { this.WriteLog(MessageType, AfterFileName, Message, null, true); }
/// <summary> /// 寫入成 Log /// </summary> /// <param name="MessageType">Log 型態</param> /// <param name="Message">內容</param> public void WriteLog(Mode.LogMode MessageType, string Message) { this.WriteLog(MessageType, null, Message, "yyyyMMdd", true); }