为什么log4net不记录我的堆栈跟踪信息? [英] Why isn't log4net logging my stack traces?
问题描述
使用首选形式
_log.Error("Message", exception)
不记录我的堆栈跟踪.为了解决这个问题,我必须通过执行以下操作来确保.ToString()得到异常的调用.
does not log my stack trace. To get around this I have to make sure the .ToString() gets call on the exception by doing the following.
_log.Error("Message" + exception);
但是我知道这是错误的,只有我不能使正确的版本正常工作.我需要在log4net.xml文件中使用特殊行来使其工作吗?
But I know that's wrong, only I can't make the correct version work. Do I need a special line in my log4net.xml file to make this work?
推荐答案
I wanted to provide my eventual answer, just for reference. I had implemented an asynchronous appender scheme for log4net using my answer to the SO question How do I create an asynchronous wrapper for log4net?
我在答复中指出,您需要注意FixFlags,因为FixFlags中没有的所有内容都会从原始日志记录事件中删除.不幸的是,我没有在原始解决方案中添加FixFlags.Exception,因此在转发过程中会丢弃所有生成的异常.
I noted in my response that you need to be careful about the FixFlags, because anything not in the FixFlags will get dropped from the original logging event. Unfortunately, I did not add FixFlags.Exception to my original solution, so any exceptions generated get dropped during the forwarding process.
从更改我的FixFlags
Changing my FixFlags from
loggingEvent.Fix = FixFlags.ThreadName;
收件人
loggingEvent.Fix = FixFlags.ThreadName | FixFlags.Exception;
解决了该问题.
这篇关于为什么log4net不记录我的堆栈跟踪信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!