InstallContext.LogMessage(String) 方法

定義

將訊息寫入主控台和安裝的記錄檔。

public:
 void LogMessage(System::String ^ message);
public void LogMessage (string message);
member this.LogMessage : string -> unit
Public Sub LogMessage (message As String)

參數

message
String

要寫入的訊息。

範例

此範例是 類別概觀中範例的 InstallContext 摘錄。

它會使用 IsParameterTrue 方法來找出是否已 LogtoConsole 設定 參數。 如果 yes為,則會使用 方法將 LogMessage 狀態消息寫入安裝記錄檔和控制台。

// Check whether the "LogtoConsole" parameter has been set.
if ( myInstallContext->IsParameterTrue( "LogtoConsole" ) )
{
   // Display the message to the console and add it to the logfile.
   myInstallContext->LogMessage( "The 'Install' method has been called" );
}
// Check whether the "LogtoConsole" parameter has been set.
if( myInstallContext.IsParameterTrue( "LogtoConsole" ) == true )
{
   // Display the message to the console and add it to the logfile.
   myInstallContext.LogMessage( "The 'Install' method has been called" );
}
' Check wether the "LogtoConsole" parameter has been set.
If myInstallContext.IsParameterTrue("LogtoConsole") = True Then
   ' Display the message to the console and add it to the logfile.
   myInstallContext.LogMessage("The 'Install' method has been called")
End If

備註

安裝程式可以呼叫這個方法,將進度或其他狀態資訊寫入記錄檔。 如果命令行參數指定應該顯示使用者介面,則安裝程式應該顯示消息框,或除了呼叫 LogMessage 方法之外進行查詢。 除非 InstallUtil.exe 用來執行安裝,而且命令行中指定了 “/LogToConsole= true” ,否則使用者不會看到寫入記錄檔的文字。

適用於

另請參閱