How to log MethodName when wrapping Log4net?

后端 未结 10 1706
说谎
说谎 2020-11-29 23:41

I have wrapped Log4net in a static wrapper and want to log

loggingEvent.LocationInformation.MethodName
loggingEvent.LocationInformation.ClassName
         


        
10条回答
  •  温柔的废话
    2020-11-30 00:27

    Just declare your log variable like this...

    private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    

    Then you can use it normaly.

提交回复
热议问题