All of this code is my own libary to be used by my client consumer applications
I have exactly the same installer as in the documentation found here. I also have a bootstrapper pretty much the same as found here, except I use: _bootStrapContainer = new WindsorContainer().Install(FromAssembly.Named("MyAssembly"));
I thought the installer would inject the Castle.Core.Logging.ILogger
into the MyLogger
class below but I always get null logger unless I resolve the MyLogger.Logger
like this:
MyLogger lgr = new MyLogger();
lgr.Logger = container.Resolve<ILogger>();
So my question is do I always have to resolve or am I not doing something correct during registration?
using Castle.Core.Logging;
public class MyLogger
{
private ILogger _logger = NullLogger.Instance;
public ILogger Logger
{
get
{
return _logger;
}
set
{
_logger = value;
}
}
}
You need to register the Windsor logging facility to enable Windsor to resolve the Logger property for you.
Here is an example of setting up the logging facility using xml and using code
Basically it boils down to:
container.AddFacility<LoggingFacility>(f => f.UseLog4Net());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With