using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.diagnostics;
namespace consoleapp
///
/// 建立系統事件日誌分類
///
/// 註冊事件源(比如說這個日誌**於某乙個應用程式)
/// 日誌名稱(事件列表顯示的名稱)
///
public static bool createsystemeventlogcategory(string eventsourcename, string logname)
createresult = true;
}catch (exception ex)
return createresult;
} ///
/// 刪除系統事件日誌分類
///
/// eventname事件源
///
public static bool removesystemeventsourcecategory(string eventsource)
cwww.cppcns.comreateresult = true;
}catch (exception ex)
return createresult;
} ///
/// 向系統日誌中寫入日誌
///
/// 事件源
/// 寫入日誌資訊
/// 日誌文字分類(警告、資訊、錯誤)
/// 程式設計客棧
public static bool writesystemeventlog(string eventsource, string msg, eventlogentrytype type)
else
}catch (exception ex)
return wr程式設計客棧iteresult;
} ///
/// 刪除事件源中logname(好像刪除了所有的該分類的日誌)
///
///
///
///
public static bool removesystemeventlog(string eventsource, string logname)
else
}catch (exception ex)
return removeresult;
} ///
/// 獲取錯誤資訊
///
///
public static string geterrormessage()}}
本文標題: c#實現寫系統日誌的方法
本文位址:
C 寫系統日誌
using system using system.collections.generic using system.linq using system.text using system.diagnostics 建立系統事件日誌分類 註冊事件源 比如說這個日誌 於某乙個應用程式 日誌名稱 事件列表...
C 寫Windows系統日誌(EventLog)
net framework 2.0開始,可以使用 event log建構函式在windows系統日誌 裡新增內容,一切看上去是如此的簡單。只是 會涉及到一點點的許可權問題,必須要注意一下。使用event log時,涉及到乙個叫做 source 的引數 一般用來記錄訊息的出處 比如將該引數設為 mye...
C 寫日誌類
using system using system.data using system.configuration using system.web using system.web.security using system.web.ui using system.web.ui.webcontro...