MoveNext instead of actual method/task name

Using log4net declared as:

private readonly ILog log = 

In an async method or task, like this one:

public async void CheckSomething()

logs MoveNext instead of CheckSomething. Any idea how to make it log an actual method name?


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 what log4net is reporting.

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

Leave a Reply

Your email address will not be published. Required fields are marked *