You could do something like this from just using configuration, but it's not exactly what you mention. If you're able to read it and don't mind the weird syntax you could use the %type
pattern to print out the qualified name of the method and then the %method
pattern to print the method. You can even only print some of the qualified name to combat long namespaces.
From the docs:
Used to output the fully qualified type name of the caller issuing the logging request. This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.
If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. By default the class name is output in fully qualified form.
For example, for the class name "log4net.Layout.PatternLayout", the pattern %type{1} will output "PatternLayout".
eg.
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger %type{2}.%method [%line] - %message%newline %exception" />
</layout>
In terms of the MoveNext
printing, it'll look like:
2021-03-10 11:45:29,203 INFO StackOverflowLogger SubNamespace.ClassName+<MethodNameAsync>d__15.MoveNext [123] - Logging is starting...
We didn't care about the d__15.MoveNext
as long as the async method was there SubNamespace.ClassName+<MethodNameAsync>
.