Console.WriteLine(
new System.Diagnostics.StackTrace().ToString()
);
The output will be similar to:
at YourNamespace.Program.executeMethod(String msg)
at YourNamespace.Program.Main(String[] args)
Replace Console.WriteLine
with your Log
method. Actually, there is
no need for .ToString()
for the Console.WriteLine case as it accepts
object
. But you may need that for your Log(string msg) method.