I have a custom layout renderer named job. It provides several items, which are used like this in our app.config:
<variable name="jobHost" value = "${job:item=host}" />
<variable name="jobService" value = "${job:item=service}" />
<variable name="jobNS" value = "${job:item=ns}" />
<variable name="jobName" value = "${job:item=name}" />
<variable name="jobKind" value = "${job:item=kind}" />
<variable name="jobScheduleId" value = "${job:item=scheduleId}" />
<variable name="jobLayout" value = "[H:${jobHost} S:${jobService} NS:${jobNS} N:'${jobName}' K:${jobKind} S:${jobScheduleId}]" />
<variable name="layout" value = "${longdate} [${threadid}] ${machinename} ${jobLayout} ${uppercase:inner=${level}} ${logger} - ${message} ${onexception:${newline}${exception:format=ToString:innerFormat=ToString:maxInnerExceptionLevel=2}}" />
<targets>
    <target name="ThreadLog" xsi:type="ThreadSpecificTarget" />
    <target xsi:type="SplitGroup" name="AllTargets">
        <target name="TextFile" xsi:type="File" fileName="C:\Log\QuartzBackgroundEngine.txt" layout="${layout}"/>
        <target name="Console" xsi:type="ColoredConsole" layout="${layout}"/>
    </target>
</targets>
When the layout renderer decides that there is no job specific data available, then log messages contain the string [H: S: NS: N:'' K: S:]. I want to exclude it. 
So, I tried to replace ${jobLayout} with ${jobLayout:when=jobName!=’’}, but it does not work, because NLog thinks that jobLayout should correspond to a layout renderer, rather than a variable, which is the case here.
How can I change my layout so that ${jobLayout} is only included if ${jobName} is not empty?
 
     
     
    