C# derived class type needed in base for logging using NLog
I am unfamiliar with NLog but in Log4Net the syntax
LogManager.GetLogger(this.GetType())
will accomplish what you want. GetType
returns the leaf type in your inheritance hierarchy, even if called in the base ApplicationController
class, when the logger is first created (ie: on first access to the Logger property) it will instantiate it with type PropertyController
NLog API is slightly different than Log4net. You need to use
Logger = LogManager.GetLogger(GetType().Name);
if you only pass the type, LogManager will expect a logger type (i.e. a custom logger)