EventLogInstaller.Source 屬性

定義

取得或設定使用記錄檔登錄的來源名稱。Gets or sets the source name to register with the log.

public:
 property System::String ^ Source { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Source { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Source { get; set; }
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Source { get; set; }
member this.Source : string with get, set
Public Property Source As String

屬性值

使用事件記錄檔登錄作為項目來源的名稱。The name to register with the event log as a source of entries. 預設為空字串 ("")。The default is an empty string ("").

屬性

備註

事件來源會指出記錄事件的原因。The event source indicates what logs the event. 這通常是應用程式的名稱, 或是大型應用程式內的元件名稱。It is often the name of the application, or the name of a component within a large application.

安裝程式會使用Source屬性的值, 將您的應用程式註冊為事件記錄檔, 做為專案的有效來源。The installer uses the value of the Source property to register your application with the event log as a valid source of entries. 新的來源名稱不能符合現有的來源名稱或現有的事件記錄檔名稱。A new source name cannot match an existing source name or an existing event log name. 每個來源一次只能寫入一個事件記錄檔;不過, 您的應用程式可以使用多個來源寫入多個事件記錄檔。Each source can only write to one event log at a time; however, your application can use multiple sources to write to multiple event logs. 例如, 您的應用程式可能需要針對不同的事件記錄檔或不同的資源檔設定多個來源。For example, your application might require multiple sources configured for different event logs or different resource files.

應用程式和服務應寫入應用程式記錄檔或自訂記錄檔。Applications and services should write to the Application log or a custom log. 設備磁碟機應該寫入系統記錄檔。Device drivers should write to the System log. 如果您未在執行安裝程式之前指定記錄檔名稱, 安裝程式會向應用程式記錄檔註冊您的來源。If you do not specify a log name before the installer runs, the installer registers your source to the Application log. 如果您指定的記錄檔名稱不存在, 系統就會Source向該記錄檔註冊, 但是在寫入第一個專案之前, 不會建立記錄檔。If you specify the name of a log that does not exist, the system registers the Source to that log, but the log is not created until the first entry is written to it.

使用EventLogInstaller為新的或現有的事件記錄檔註冊新的來源, 請勿使用EventLogInstaller來變更現有的來源。Use EventLogInstaller to register a new source for a new or existing event log; do not use EventLogInstaller to change an existing source. EventLogInstaller類別不會修改現有來源的設定屬性, 以符合指定的安裝內容。The EventLogInstaller class does not modify the configuration properties of an existing source to match the specified installation properties. 如果屬性符合針對電腦上的不同事件記錄檔註冊的來源名稱,方法會擲回例外狀況。Install SourceThe Install method throws an exception if the Source property matches a source name that is registered for a different event log on the computer. 如果屬性符合已為Install Log屬性中指定的相同事件記錄檔註冊的來源名稱, 則方法不會註冊來源。 SourceThe Install method does not register the source if the Source property matches a source name that is already registered for the same event log specified in the Log property.

如需事件記錄檔和來源行為的詳細資訊, 請參閱EventLog LogSource屬性的類別檔。For more detailed information about the behaviors of event logs and sources, see the EventLog class documentation for the Log and Source properties.

適用於

另請參閱