NLog LogException似乎忽略了该异常

编程入门 行业动态 更新时间:2024-10-21 11:29:21
本文介绍了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()

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

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似乎忽略了该异常

本文发布于:2023-11-24 09:03:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:异常   忽略了   NLog   LogException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!