Question

I need to use the percentage char within the value attribute of the XmlFile element to configure path of log4net rolling file appender while application is installed.

Target is to get log4net configured like this

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
   <file type="log4net.Util.PatternString" value="Log_[%processid].log" />
   ...
</appender>

The base wix code looks like this:

<util:XmlFile
   Id="RollingFileAppenderLogPath"
   File="[INSTALLLOCATION]log4net.config" Action="setValue" Permanent="yes"
   ElementPath="/log4net/appender[\[]@name='RollingFileAppender'[\]]/file" Name="value"
   Value="[LOGPATH]Log_[%processid].log"/>

I've tried some various replacements for [ ] and % like entities (&#91;, &#93; and &#37;), doubling, tripling, quadrupling but the value is always mentioned as environment variable or causes ICE03: Invalid string format.

The replacement result looks like this:

<file type="log4net.Util.PatternString" value="<inserted LOGPATH>Log_.log"/>

Is there a way to get [%processid] forced as string to get it inserted as intended?

Was it helpful?

Solution

Think I found the solution: the problem is with the square brackets!

If you open the WIX Documentation and navigate to the "XmlFile Element", on the "Value" property it reads:

The value to be written. See the Formatted topic for information how to escape square brackets in the value.

So, just ckeck the link above and alter the text, escaping the square brackets and all should work fine! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top