MOVENEXT,而不是实际的方法/任务名称 [英] MoveNext instead of actual method/task name
问题描述
使用声明log4net的:
Using log4net declared as:
private readonly ILog log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType());
在异步方法或任务,像这样的:
In an async method or task, like this one:
public async void CheckSomething()
{
log.Info(null);
//....
}
日志的MoveNext
而不是 CheckSomething
。
任何想法如何使它登录一个实际的方法名?
logs MoveNext
instead of CheckSomething
.
Any idea how to make it log an actual method name?
推荐答案
所有异步
方法被改写成状态机来满足潜在的await
方法内的值。其中code生活的最后一个方法是为whot log4net的
的报告的MoveNext
方法。
All async
methods are rewritten into a state machine to satisfy potential await
values within the method. The final method in which the code lives is the MoveNext
method which is whot log4net
is reporting.
有真的在运行时转换从的MoveNext
来,其中code最初写的实际方法没有什么好办法。它们在元数据水平有所断开。您可能只需要诉诸直接登录名称
There is really no good way at runtime to transition from MoveNext
to the actual method in which the code was originally written. They are somewhat disconnected at a metadata level. You may just have to resort to logging the name directly
这篇关于MOVENEXT,而不是实际的方法/任务名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!