ServiceBase.AutoLog 屬性

定義

指示是否在事件記錄檔中報告啟動、停止、暫停和繼續等命令。Indicates whether to report Start, Stop, Pause, and Continue commands in the event log.

public:
 property bool AutoLog { bool get(); void set(bool value); };
[System.ServiceProcess.ServiceProcessDescription("SBAutoLog")]
public bool AutoLog { get; set; }
member this.AutoLog : bool with get, set
Public Property AutoLog As Boolean

屬性值

若要在事件記錄檔中報告資訊,則為 true,否則為 falsetrue to report information in the event log; otherwise, false.

屬性

備註

AutoLog設定true為會指示服務使用應用程式事件記錄檔來報告命令失敗,以及服務上啟動、停止、暫停和繼續事件的狀態變更資訊。Setting AutoLog to true instructs the service to use the Application event log to report command failures, as well as state change information for Start, Stop, Pause, and Continue events on the service. 服務的名稱會當做記錄檔的EventLog.Source使用。The name of the service is used as the log's EventLog.Source.

若要將資訊報告到自訂事件記錄檔,而不是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.

注意

提供ServiceName事件記錄檔之來源字串的必須先設定,服務才會嘗試寫入事件記錄檔。The ServiceName, which supplies the source string for the event log, must be set before the service attempts to write to the event log. 在設定來源名稱之前嘗試存取事件記錄檔,會擲回例外狀況。Trying to access the event log before the source name is set throws an exception.

適用於

另請參閱