问题描述
我正在使用Log4Net记录多层企业应用程序.
I'm using Log4Net to log a multilayer-ed Enterprise Application.
我知道,当我使用Log4Net记录异常时,它会自动公开异常StackTrace,但是我想为每个日志调用记录StackTrace,即使这些不是异常抛出也是如此.
I know that when I log an exception with Log4Net, it automatically exposes the exception StackTrace, but I want to log the StackTrace for every log call, even if those are not exception throws.
我为什么需要那个?我想知道日志的呼叫来源(向下钻取图层...)
Why do I need that?...I want to know the call origin of the log (drilldown the layers...)
谢谢...
蒂亚戈·迪亚斯
推荐答案
我找到了解决我问题的方法.我用自己的方法包装了log4net,并创建了LoggingEvent实例.在每种情况下,我都使用了Environment.StackTrace属性.
I came to a solution to my problem.I've wrap around the log4net in my own methods and i've created LoggingEvent intances. In each instance i've used a property with Environment.StackTrace.
这样,即使没有引发异常,我的应用程序中也有StackTrace foreach日志事件.
This way i have StackTrace foreach log event in my application, even without exceptions being throwned.
谢谢大家.
这篇关于如何在log4net的每个日志调用中添加StackTrace?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!