[转]How to tell NLog to log exceptions?

本文转自:https://stackoverflow.com/questions/9199073/how-to-tell-nlog-to-log-exceptions

 

问:

Target:

<targets>
    <target name="file" xsi:type="File" layout="${longdate} ${level} ${message} ${exception}" fileName="${basedir}/log.txt" archiveAboveSize="10485760" />
</targets>

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?

 

 

答:

I've found ${exception:format=tostring} to be the best format for logging full details.

NLog - How to Log Exceptions

 

posted on 2017-12-20 10:28  freeliver54  阅读(199)  评论(0编辑  收藏  举报

导航