在 XmlFile 的值中使用百分比字符
我需要在安装应用程序时使用 XmlFile 元素的 value 属性中的百分比字符来配置 log4net 滚动文件附加程序的路径。
目标是像这样配置 log4net
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="Log_[%processid].log" />
...
</appender>
基本 wix 代码如下所示:
<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"/>
我尝试了 [ ] 和 % 之类的实体([、] 和 %)的各种替换,加倍、三倍、四倍,但该值始终作为环境变量提及或导致 ICE03:无效的字符串格式。
替换结果如下所示:
<file type="log4net.Util.PatternString" value="<inserted LOGPATH>Log_.log"/>
有没有办法将 [%processid] 强制作为字符串以按预期插入?
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 ([, ] and %), 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我找到了解决方案:问题出在方括号上!
如果您打开 WIX 文档并导航到“XmlFile Element”,则“Value”属性上显示:
因此,只需检查上面的链接并更改文本,转义方括号,一切都应该可以正常工作! :)
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:
So, just ckeck the link above and alter the text, escaping the square brackets and all should work fine! :)