Logging: how to get Class and Method names

When logging errors is helps to have the Class and method names where the exception was thrown without using string constants that are a pain to maintain. The code to get the names is

Current assembly and class name = Me.GetType.FullName
Current class name = Me.GetType.Name
Current method (function or sub) = System.Reflection.MethodBase.GetCurrentMethod().Name

This entry was posted in VB.NET. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>