LogMessage日志
安装程序可以调用此方法以将进度信息或其他状态信息写入日志文件。如果命令行参数指定应显示用户界面,则除调用 LogMessage 方法之外,安装程序还应显示消息框或进行查询。除非使用 InstallUtil.exe 来运行安装,并在命令行中指定“/LogToConsole= true”,否则用户不会看到写入日志文件的文本。
示例
[Visual Basic, C#, C++] 此示例为 InstallContext 类的类概述中的示例摘录。
[Visual Basic, C#, C++] 它使用 IsParameterTrue 方法查看是否已经设置 LogtoConsole 参数。如果为 yes,它将使用 LogMessage 方法将状态消息写入安装日志文件和控制台。
[Visual Basic]
' 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
[C#]
// 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" );
}
[C++]
// Check whether the S"LogtoConsole" parameter has been set.
if (myInstallContext->IsParameterTrue(S"LogtoConsole")) {
// Display the message to the console and add it to the logfile.
myInstallContext->LogMessage(S"The 'Install' method has been called");
}
codeproject相关文章:
http://www.codeproject.com/info/search.asp
Microsoft相关:
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpguide/html/cpconOpeningAppendingToLogFile.asp
示例
[Visual Basic, C#, C++] 此示例为 InstallContext 类的类概述中的示例摘录。
[Visual Basic, C#, C++] 它使用 IsParameterTrue 方法查看是否已经设置 LogtoConsole 参数。如果为 yes,它将使用 LogMessage 方法将状态消息写入安装日志文件和控制台。
[Visual Basic]
' 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
[C#]
// 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" );
}
[C++]
// Check whether the S"LogtoConsole" parameter has been set.
if (myInstallContext->IsParameterTrue(S"LogtoConsole")) {
// Display the message to the console and add it to the logfile.
myInstallContext->LogMessage(S"The 'Install' method has been called");
}
codeproject相关文章:
http://www.codeproject.com/info/search.asp
Microsoft相关:
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpguide/html/cpconOpeningAppendingToLogFile.asp