I am trying to figure out why NLog logs my error twice.
here is my config file:
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="debug" xsi:type="File" FileName="DebugTestFile.log" layout="${message} ${exception:format=tostring}" />
</targets>
<rules>
<logger name="*" level="Debug" writeTo="debug" />
</rules>
</nlog>
Now when I call NLog.Debug(myException);
the output is my exception gets printed twice.
If I call NLog.Debug(myException, "My Test Message String");
then the error gets printed out once along with my test message.
What exactly am I doing wrong? According to https://github.com/NLog/NLog/wiki/How-to-Log-Exceptions my configuration is correct.
I tried changing my layout to the following: layout="${message}
and when I ran NLog.Debug(myException);
it only printed the error once.
However now when I ran NLog.Debug(myException, "My Test Message String");
it only printed my message without the error that comes from exception.
Could this be a bug with NLog?
NLog.Debug(myException, myMessage);
which doesn't do that, and my message is an empty string. – Devolution