How to apply different layouts to the same target in NLog?
An alternate solution is to use the when condition in the layout.
target.Layout = "${longdate}|[${level}]|${logger}|${message}${onexception:inner=|${exception}${when:when=(level > LogLevel.Warn):inner=|[!] ${exception:format=ToString:innerFormat=Message:maxInnerExceptionLevel=5} }}"
I wanted to just provide the exception message when anything less than error. When there was an error I wanted full stack trace.