为什么 NLog 没有按预期记录?
Why is the NLog not logging as expected?
我正在试用 NLog,但遇到了一些问题。
这是示例项目:Sample Link for Project Reference
这些就是问题所在:
- 为什么我在日志文件中没有得到完整的异常?没有堆栈跟踪?
Edit : There is a Layout on the target tag that I missed, I added this
:
${longdate} ${uppercase:${level}} ${message} | ${stacktrace}
Now I get a stacktrace but its not complete, its looks like this :
Control.WndProcException => ThreadContext.OnThreadException => Program.Application_ThreadException
So no info about the btThrowException_Click where the exception was
thrown?
- 有时根本不登录?就像它被缓存但从未刷新一样?为什么?
你可以使用这个:
layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=ToString,StackTrace:maxInnerExceptionLevel=2} ${newline}"
默认情况下,NLog 会执行此 "compact" 异常。如果您添加此布局,那么您将获得最多 2 级内部异常的完整异常。
关于第二个错误,我没有遇到过。也许你应该提供更多细节。
我正在试用 NLog,但遇到了一些问题。
这是示例项目:Sample Link for Project Reference
这些就是问题所在:
- 为什么我在日志文件中没有得到完整的异常?没有堆栈跟踪?
Edit : There is a Layout on the target tag that I missed, I added this :
${longdate} ${uppercase:${level}} ${message} | ${stacktrace}
Now I get a stacktrace but its not complete, its looks like this :
Control.WndProcException => ThreadContext.OnThreadException => Program.Application_ThreadException
So no info about the btThrowException_Click where the exception was thrown?
- 有时根本不登录?就像它被缓存但从未刷新一样?为什么?
你可以使用这个:
layout="${longdate} ${uppercase:${level}} ${message} ${exception:format=ToString,StackTrace:maxInnerExceptionLevel=2} ${newline}"
默认情况下,NLog 会执行此 "compact" 异常。如果您添加此布局,那么您将获得最多 2 级内部异常的完整异常。
关于第二个错误,我没有遇到过。也许你应该提供更多细节。