【发布时间】:2014-07-09 12:45:46
【问题描述】:
我正在将函数调用记录到日志文件中。
我也在使用log4Net
public Registration Check(Registration registration)
{
loggingProvider.Entry();
//Some code Here
loggingProvider.Exit();
return something;
}
现在如果我必须输入一个函数调用,我必须在每个函数中手动添加loggingProvider.Entry()。
有没有一种方法可以记录在给定命名空间内发生的所有函数调用,并且 LOC 最少?就像在一个地方编写一个函数来记录所有发生的函数调用?
我尝试使用stacktrace 来get the name of the function being called from the constructor/destructor 并记录它,但这是不可能的。
请提供任何替代方法来获取正在调用的函数名称,而无需在每个函数中手动添加日志函数。
【问题讨论】: