目标:
<targets>
<target name="file" xsi:type="File" layout="${longdate} ${level} ${message} ${exception}" fileName="${basedir}/log.txt" archiveAboveSize="10485760" />
</targets>
当我打电话时
Logger.Error("some message", e)
,其中 e
是一些异常对象,它只记录消息,不记录异常信息。我需要它来输出异常消息和堆栈跟踪。任何想法我做错了什么?
最佳答案
尝试使用 ${exception:innerFormat=Message,StackTrace}
.这是documentation .
关于nlog - 如何告诉 NLog 记录异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9199073/