forum

Home / DeveloperSection / Forums / How to get class name?

How to get class name?

Lillian Martin 1759 18-Jan-2015

How to get the class-name with caller info attributes.

I strongly say a no to log the class name using reflection.

Was able to get the method name using the [CallerMemberName] like below:

        private void Log(string logMessage, [CallerMemberName]string callerName = null)
        {
            if (logger.IsDebugEnabled)
            {
                logger.DebugFormat("Executing Method = {1};{0}", logMessage, callerName);
            }
        }

How to log the class name here using Caller Info Attributes ?


Updated on 18-Jan-2015

Can you answer this question?


Answer

1 Answers

Liked By