Question

I am authoring a project template for SharpDevelop 4.1 and one of the files in this template is an XML config file which contains NLog configuration. The problem is that NLog layouts and variable substitution for the SharpDevelop template itself use the same syntax. Namely the ${time} in the layout is the problem:

<target xsi:type="File" name="file" layout="${time} ${level} ${logger} ${message}" fileName="${ProjectName}.log" />

It is intended to be output into the resulting file as is, however, the SharpDevelop template expansion is replacing it with the time the template is expanded:

<target xsi:type="File" name="file" layout="10:37 AM ${level} ${logger} ${message}" fileName="TestProject.log" />

I still need the ${ProjectName} substitution. How can I prevent or work-around the ${time} substitution?

Was it helpful?

Solution

After looking through SharpDevelop's source code in the StringParser class, it appears there is no escape mechanism for tags.

But I can work around it by modifying the NLog layout renderer so it no longer matches the SharpDevelop tag but still has the same effect in NLog:

<target xsi:type="File" name="file" layout="${time:universalTime=False} ${level} ${logger} ${message}" fileName="${ProjectName}.log" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top