Nov 272012

I love Ninject, and I love log4net. I tend to pull them in to any project that I’m working on. And Ninject provides great support through its Ninject.Extensions.Logging package for getting log4net loggers injected into your classes with very little work. But one thing always bugged me: you have to put an [Inject] attribute on every ILogger property that you want injected. I hate that, because it scatters Ninject all over your implementation classes, and as a general rule your classes should be agnostic toward whatever IoC container you happen to be using. So, I created the NinjectAutoLogging package to allow for automatically injecting ILogger properties without the need for the attribute. Continue reading »

May 242012

NOTE: I have since solved this problem with a Ninject module that makes things much simpler. Check out this post for details.

This post describes a pattern I came up with for providing logging in an application is a very elegant way, with consumers of loggers able to use loggers that are injected via property injection. But, at test time if the logger is null, a NullReferenceException is prevented so that tests can be executed without having to provide a mocked logging interface.
Continue reading »