You could also just use MethodBase.GetCurrentMethod().
This returns the MethodInfo of the currently executing
method. Both classes are in the System.Reflection
namespace.
Ooops. Sorry, I did not read your post entirely ;-). You
can delete my comment.
Any sort of overhead that one should be concerned about
when using either of these techniques (StackTrace or
MethodBase) considering that the tracing code would
actually be part of the production code? Both the
techniques are indeed very useful to log trace
statements but when we're speaking of thousands of
users, would the method calls have any effect on
performance whatsoever (compared to just sticking in
string constants)?
Thanks!
You probably don't want to catch Exception, if the JIT
fails to JIT a method, or if an assembly is missing or a
attribute's constructors throws an exception you are
going to catch and handle these exactly the same; by
ignoring them. Not real good practice.