2010-12-18 39 views
-2

只是想知道在Windows 7中創建一個日誌類別,我在XP上得到它,但在Windows 7中有點混淆,任何想法?在Windows 7中創建自定義日誌類別,C#

if (!System.Diagnostics.EventLog.SourceExists("MyReminderService")) 
    EventLog.CreateEventSource("MyReminderService", "MyReminderServiceLog"); 

EventLog log = new EventLog("MyReminderServiceLog"); 
log.Source = "MyReminderServiceLog"; 
log.WriteEntry("The Exeption message..."); 
+0

有沒有錯誤? – 2010-12-18 07:33:00

回答

2

這是用於Windows XP和Windows 7可能無法在Windows 7開箱的原因是因爲你可能會需要管理員權限(你在默認情況下在Windows XP)到同創建事件日誌源。

以管理員身份運行您的應用程序,它可能會工作。