ServiceBase.EventLog 屬性


取得事件記錄檔,您可以利用該事件記錄將服務命令呼叫 (例如啟動和停止) 通知寫入應用程式事件記錄檔。Gets an event log you can use to write notification of service command calls, such as Start and Stop, to the Application event log.

 virtual property System::Diagnostics::EventLog ^ EventLog { System::Diagnostics::EventLog ^ get(); };
public virtual System.Diagnostics.EventLog EventLog { get; }
member this.EventLog : System.Diagnostics.EventLog
Public Overridable ReadOnly Property EventLog As EventLog


EventLog 執行個體,其來源是登錄到應用程式記錄檔。An EventLog instance whose source is registered to the Application log.



此函式會EventLog將屬性初始化為已設定EventLog.SourceEventLog.Log屬性的實例。The constructor initializes the EventLog property to an instance with the EventLog.Source and EventLog.Log properties set. 來源是ServiceName服務的,而記錄檔則是電腦的應用程式記錄檔。The source is the ServiceName of the service, and the log is the computer's Application log. 這些值會自動設定,而且無法變更以自動記錄服務命令。These values are set automatically and cannot be changed for automatic logging of service commands.

AutoLogtrue時,啟動、停止、暫停、繼續和自訂命令會自動記錄在應用程式事件記錄檔中。When AutoLog is true, Start, Stop, Pause, Continue, and custom commands are recorded automatically in the Application event log. 您也可以使用EventLog屬性,將其他訊息寫入該記錄檔。You can use the EventLog property to write additional messages to that log as well. 使用這個EventLog.WriteEntry EventLog成員呼叫的元件。The component calls EventLog.WriteEntry using this EventLog member.

若要將資訊報告到自訂事件記錄檔,而不是AutoLog應用false程式記錄檔,請將設定為, OnContinue並在命令OnStop處理方法、 OnPause或中撰寫指示,以張貼至適當的記錄檔。To report information to a custom event log rather than the Application log, set AutoLog to false and write instructions within the command-handling methods OnContinue, OnPause, or OnStop to post to the appropriate log.