C# 写系统日志
时间:2011-05-20 来源:育慧
public class SystemEventLog { private static EventLog mLog; /// <summary> /// 返回操作Windows日志的类。 /// </summary> public static EventLog Log { get { if (mLog == null) { InitSystemEventLog(); } return mLog; } } /// <summary> /// 初始化系统事件日志 /// </summary> private static void InitSystemEventLog() { string sEventLogSource = "FDC"; if (!EventLog.SourceExists(sEventLogSource)) { EventLog.CreateEventSource(sEventLogSource, "FDCLOG"); new EventLog("FDCLOG").MaximumKilobytes = 500 * 1024; } mLog = new EventLog(); mLog.Source = sEventLogSource; } }
相关阅读 更多 +