variablesloggingpathwixbootstrapper

How to set custom value to Wix Bundle Log Element?


If I put a hard-coded value it works fine

<Log PathVariable="C:\myProjectDir\myLogs\log.txt"/>

 

But if I make a separate variable and replace the hard-code, it does NOT work

<Log PathVariable="[LogLocation]"/>
<Variable Name="LogLocation" bal:Overridable="no" Type="string" Value="C:\myProjectDir\myLogs\log.txt" Persisted="yes"/>

 

I found something on the lines of <WixVariable Id="WixBundleLog"/> but I don't really know how to use it.

My end goal here is that I have a bootstrapper application and I want to change the location where logs of my msi and exe installation is created

I able able to change a Variable element value using _bootstrapper.Engine.StringVariables["LogLocation"] = "C:\ProjectGorilla\logs\log.txt"

Using the above code in C#, the Variable Id="LogLocation" is changed but that change is not reflected in Log element's PathVariable

So, my question is how can I put a variable in PathVariable attribute of Log element

Thanks in advance :)


Solution

  • According to the documentation, the PathVariable attribute is:

    Name of a Variable that will hold the path to the log file. An empty value will cause the variable to not be set. The default is "WixBundleLog".

    PathVariable does not specify the path where the (bundle) log will be written. It is a variable that the BA is supposed to read if it wants to copy the file somewhere else. The Burn engine never reads this variable's value so changing it during runtime won't do anything.

    The (bundle) log is created (https://github.com/wixtoolset/wix3/blob/58abd6993afba08b39e37b0e76b1790161df9231/src/burn/engine/engine.cpp#L499) before loading the BootstrapperApplication (https://github.com/wixtoolset/wix3/blob/58abd6993afba08b39e37b0e76b1790161df9231/src/burn/engine/engine.cpp#L545). There is no way for the BA to change the path.

    The package (MSI, EXE, etc) log locations work the same way today as the bundle log. However since they are created after loading the BA, it's theoretically possible that someone could implement a feature so that the BA can change their path.