Cant apply transform for NLog.config

Feb 15, 2011 at 3:48 PM

Original.config:

 

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	  autoReload="true">

	<targets>
		<target name="fileLog" xsi:type="File"
				fileName="${basedir}/Logs/${shortdate}.log"
				layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${logger}|${message} ${exception:format=tostring}"
				header="----- Start of log -----"
				footer="----- End of log -----" />

		<target name="consoleLog" xsi:type="Console"
				layout="${date:format=HH\:mm\:ss}|${logger}|${message} ${exception:format=tostring}" />

		<target name="mailLog" xsi:type="Mail"
				layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${logger}|${message} ${exception:format=tostring}"
				header="----- Start of log -----"
				footer="----- End of log -----"
				smtpServer="smtp.gmail.com"
				smtpPort="587"
				smtpAuthentication="Basic"
				smtpUserName="DEV@gmail.com"
				smtpPassword="somepass"
				enableSsl="true"
				from="DEV@gmail.com"
				to="me@gmail.com"
				subject="[DEV:Service] Log message" />
	</targets>

	<rules>
		<logger name="*" minlevel="Trace" writeTo="fileLog" />
		<logger name="*" minlevel="Trace" writeTo="consoleLog" />
		<logger name="*" minlevel="Trace" writeTo="mailLog" />
	</rules>
</nlog>

 

Transform.config:

 

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<targets>
		<target name="mailLog" xsi:type="Mail"
				layout="${date:format=yyyy-MM-dd HH\:mm\:ss}|${logger}|${message} ${exception:format=tostring}"
				header="----- Start of log -----"
				footer="----- End of log -----"
				smtpServer="smtp.gmail.com"
				smtpPort="587"
				smtpAuthentication="Basic"
				smtpUserName="PROD@gmail.com"
				smtpPassword="someotherpass"
				enableSsl="true"
				from="PROD@gmail.com"
				to="me@gmail.com"
				subject="[PROD:Service] Log message"
				xdt:Locator="Match(name)" xdt:Transform="SetAttributes"/>
	</targets>
</nlog>

 

Console output:

Create Transformation Task.
Start tranformation to 'NLog.DEST.config'.
Source file: 'NLog.config'.
Transform  file: 'NLog.Release.config'.
File: , LineNumber: 2, LinePosition: 2, Message: No element in the source document matches '/nlog'
Not executing SetAttributes (transform line 18, 31)

 

I can not understand why is not working?

Feb 15, 2011 at 4:51 PM

Looks like this is general problem of XDT transformation, you can find a lot of problems with that http://www.google.co.uk/search?hl=en&q=xdt+No+element+in+the+source+document+matches+%27%2Fnlog%27&meta=

You can find solution for example here http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9ededb66-3e34-4bba-8e20-a2cc6025f0f9/