I am attempting to use Ninject with my application logging wrapper.
Here is the wrapper:
public class NLogLogger : ILogger
{
private readonly Logger _logger;
public NLogLogger(Type t)
{
_logger = LogManager.GetLogger(t.Name);
}
}
As you can see I am passing the type into the loggers constrctor, so I would use it like the following:
public class EntityObject
{
public ILogger Logger { get; set; }
public EntityObject()
{
Logger = new NLogLogger(typeof(EntityObject));
}
}
Now I cannot seem to find out how to do something similar with using Ninject. Here is my binding module:
public class LoggerModule : NinjectModule
{
public override void Load()
{
Bind<ILogger>().To<NLogLogger>();
}
}
Now obviously I get an exception thrown because it cannot inject the type into the constructor. Any ideas how I can do this?
Error activating Type
No matching bindings are available, and the type is not self-bindable.
Activation path:
4) Injection of dependency Type into parameter t of constructor of type NLogLogger
3) Injection of dependency ILogger into parameter logger of constructor of type NzbGetSettingsService
2) Injection of dependency ISettingsService{NzbGetSettingsDto} into parameter nzbGetService of constructor of type DashboardController
1) Request for DashboardController