如何告诉NLog记录异常? [英] How to tell NLog to log exceptions?
本文介绍了如何告诉NLog记录异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目标:
<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
是某些异常对象,它仅记录消息,而不记录异常信息.我需要它来输出异常消息和堆栈跟踪.有什么想法我做错了吗?
When I call Logger.Error("some message", e)
, where e
is some exception object, it only logs the message, not the exception information. I need it to output exception message and stack trace. Any ideas what I am doing wrong?
推荐答案
尝试使用${exception:innerFormat=Message,StackTrace}
.这是文档.
这篇关于如何告诉NLog记录异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文