NLog LogException似乎忽略了该异常 [英] NLog LogException seems to ignore the exception

查看:215
本文介绍了NLog LogException似乎忽略了该异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LogException或任何派生函数(例如ErrorException等)似乎完全忽略了传入的异常参数.

LogException or any of the derived functions like ErrorException etc. seem to totally ignore the exception parameter passed in.

我在nlog.config文件中缺少格式属性吗? 我正在使用Nlog在VS中安装的模板中的样板.

Am I missing a format attribute in my nlog.config file? I am using the boilerplate from the template that Nlog installs in VS.

我希望将来自异常对象和内部异常的信息添加到日志文件中.但是,添加到日志文件的唯一信息是传递给函数的字符串参数.

I would expect information from the exception object AND inner exceptions to be added to the log file. Yet the only information added to the log file is the string parameter passed to the function.

事实证明,ErrorException()实际上没有Error()

Turns out that ErrorException() is actually less useful than Error()

如何获得更多的深度报告.特别是所有内部ExceptionsMessage属性的完整递归转储?

How can I get more in depth reporting. Particularly a full recursive dump of the Message property of all inner Exceptions?

推荐答案

在布局配置中将${exception}标签添加或替换为${exception:format=tostring}

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>

这篇关于NLog LogException似乎忽略了该异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆