3

使用首选形式

_log.Error("Message", exception)

不记录我的堆栈跟踪。为了解决这个问题,我必须确保 .ToString() 通过执行以下操作来调用异常。

_log.Error("Message" + exception);

但我知道那是错误的,只是我无法使正确的版本工作。我需要在我的 log4net.xml 文件中添加一个特殊的行来完成这项工作吗?

4

1 回答 1

2

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?

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.

Changing my FixFlags from

loggingEvent.Fix = FixFlags.ThreadName;

To

loggingEvent.Fix = FixFlags.ThreadName | FixFlags.Exception;

Fixed the issue.

于 2012-07-19T13:33:04.103 回答