Class MyLog
- Namespace
- ZapLib
- Assembly
- ZapLib.dll
紀錄事件與日誌工具
public class MyLog
- Inheritance
-
MyLog
- Inherited Members
Constructors
MyLog()
建構子,可指定 log 檔案名稱預設將以今天 yyyyMMdd 形式命名,也可自行指定其他日期,以利讀取
public MyLog()
MyLog(string)
建構子,可指定 log 檔案名稱,預設將以今天 yyyyMMdd 形式命名,也可自行指定其他日期,以利讀取
public MyLog(string Name)
Parameters
Namestring日誌檔名,預設今天 yyyyMMdd
Properties
LastWritePath
最後一次 Log 檔案寫入位置
public string LastWritePath { get; set; }
Property Value
Name
日誌名稱,預設以 yyyy-mm-dd 進行命名,每天只會產生一個檔案
public string Name { get; set; }
Property Value
PageSize
讀取 log 的批次大小,預設 1mb
public int PageSize { get; set; }
Property Value
Path
日誌存放路徑
public string Path { get; set; }
Property Value
SilentMode
使否啟用安靜模式,預設為 NULL,啟用後本類別將不再寫檔
public string SilentMode { get; set; }
Property Value
Methods
Event(Exception, EventLogEntryType, string, string, int)
將例外物件記錄到 Windows 事件檢視器中
public void Event(Exception ex, EventLogEntryType type = EventLogEntryType.Error, string ProjectName = "", string CodePath = "", int LineNumber = 0)
Parameters
exException例外物件
typeEventLogEntryType事件類型,預設為 Error
ProjectNamestring請勿設定
CodePathstring請勿設定
LineNumberint請勿設定
Event(string, EventLogEntryType, string, string, int)
將指定訊息記錄到 Windows 事件檢視器中
public void Event(string msg, EventLogEntryType type = EventLogEntryType.Information, string ProjectName = "", string CodePath = "", int LineNumber = 0)
Parameters
msgstring指定訊息
typeEventLogEntryType事件類型,預設為 Information
ProjectNamestring請勿設定
CodePathstring請勿設定
LineNumberint請勿設定
Read(int)
使用翻頁的機制,從後往前讀取指定的 log 檔案
public ModelLog Read(int page = 1)
Parameters
pageint頁數,預設第 1 頁
Returns
- ModelLog
Log 讀取結果資料模型
Write(string)
將訊息寫入實體日誌檔案,優先採用指定路徑,第二採用 Config 設定中的 MyLog,第三採用 Config 設定中的 Storage
public void Write(string msg)
Parameters
msgstring訊息