My NLog is configured as follows
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <targets>
      <target name="file" xsi:type="File" fileName="${basedir}/log${shortdate}.txt" archiveAboveSize="500000" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="10" layout="${date:format=s}|${level}|${callsite}|${identity}|${message}|${exception:format=stacktrace}"/>
      <!--<target name="console" xsi:type="Console" />-->
    </targets>
    <rules>
      <logger name="*" minlevel="Debug" writeTo="file" />
      <!--<logger name="*" minlevel="Debug" writeTo="console" />-->
    </rules>
  </nlog>
But the stacktrace is not being logged when exception occurs. Is there a bug in NLog?
I have created a wrapper around Nlog and I am logging as follows
public void Error(string message, Exception ex)
    {
        logger.Error(message, ex);
    }
I get the message in the log but not the stacktrace.
Thanks in advance
Try this in your layout:
${exception:format=ToString}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With