我已經使用windows服務項目模板創建了工廠C#Windows服務的運行。我已經能夠正確地安裝它,並且無任何問題地啓動和停止它。爲什麼我的Windows服務日誌不會顯示在應用程序事件日誌中?
但是,當我去我的事件查看器查看它的啓動和停止日誌時,我什麼都沒有。
這裏的示例代碼我測試:
public MyService()
{
InitializeComponent();
ServiceName = "My Data Service";
EventLog.Log = "Application";
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("Starting My Data Service");
}
protected override void OnStop()
{
EventLog.WriteEntry("Ending MyData Service");
}
而且,我的操作系統是Windows Vista中。