I am interested in learning more about how people inject logging with dependency injection platforms. Although the links below and my examples refer to log4net and Unity, I
I'm using Ninject to resolve the current class name for the logger instance like this:
kernel.Bind().To()
.WithConstructorArgument("currentClassName", x => x.Request.ParentContext.Request.Service.FullName);
The constructor of a NLog Implementation could look like this:
public NLogLogger(string currentClassName)
{
_logger = LogManager.GetLogger(currentClassName);
}
This approach should work with other IOC containers as well, I guess.