I have been using WiX for a few weeks now and still finding it hard to get good information about how things are supposed to work. One of those is logging. I have a requirement to have the installer write a log file to a specific location without the user having to add any /l command line parameters. I see there is a Log command, but it's parent is Bundle, the root element for creating bundled packages. I have a simple installer, so probably not needed for my case. This should be easy, right?
1. This is the simplest solution (If I were you I would do this) - create a batch file which executes the following command:
msiexec /i MyProduct.msi /L*V "%TEMP%\MyProduct.log"
Edit the path in the batch file to the custom path that you want.
2. You can make use of the MSILogging Property to set the logging outside of the command line. But this property is only available from Windows Installer 4.0.
Basically, you need to add a new property within your .wxs file:
<Property Id="MsiLogging" Value="voicewarmupx!"/>
v – Verbose outputo – Out-of-disk-space messagesi – Status messagesc – Initial UI parameterse – All error messagesw – Non-fatal warningsa – Startup of actionsr – Action-specific recordsm – Out-of-memory or fatal exit informationu – User requestsp – Terminal properties! – Flush each line to the logx – Extra debugging informationThis will ensure that the log file will be created in the %temp% folder, the name of the log file will be something like "MSI*.LOG." The full path to the log file can be read from this property and MsiLogFileLocation. But the MsiLogFileLocation property is read only and cannot be set.
Now this doesn't satisfy your requirement to create the log file in the custom location as we are not able to set the log file location. The reason we can't set the log file location inside WIX is because we need to tell MSIEXEC where to write the log file to before the windows installer engine actually starts executing the MSI.
To fix this, one thing that you can do is to add a custom action and copy the log file from the %temp% folder to the folder that you want. It would be something like this:
<CustomAction Id="CopyLogFile" Execute="immediate"
ExeCommand="cmd /c copy [MsiLogFileLocation] C:\customlocation\MyProduct.log"
Directory="TARGETDIR"
Impersonate="no"
Return="asyncNoWait" />
<InstallExecuteSequence>
<Custom Action="CopyLogFile" OnExit="success" />
</InstallExecuteSequence>
Look in:
C:\Users\user-id\AppData\Local\Temp\Charting_Companion_YYYYMMDDhhmmss_000_Setup.log
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With