NLog LogException seems to ignore the exception

≯℡__Kan透↙ 提交于 2019-12-03 01:04:17
Niki

Add or replace the ${exception} tag in the layout config to ${exception:format=tostring}

 <targets>
    <target name="errorLogFile" xsi:type="File" fileName="errors.txt" 
            layout="${message} ${exception:format=tostring}"/>
</targets>
chrisortman

Building on @Niki's answer, this will give you pretty close to what log4net will do

fileName="${basedir}/logs/${shortdate}.log" layout="${longdate}|${level:uppercase=true}|${logger}|${message}${onexception:inner=${newline}${exception:format=tostring}}"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!