views:

249

answers:

2

Is there a way to get Ninject to log out what it is doing?

In particular I'd like to see when objects are being created. As I have a mix of transient and singleton objects it'd be very useful for me during debug to be able to see how many instances of each are being created so that I can fix object scopes where needed.

EDIT: N.B. I'm looking at Ninject 2 as found at http://github.com/enkari/ninject

+1  A: 

v1.x answer: Yes, via log adapters for a.o. log4net and NLog - see http://mhinze.com/logging-with-ninject/

[in response to comment] EDIT: v2.0 Beta answer: No:-

From Ninject 2 Reaches Beta!

Things that were in Ninject 1.x that are not in Ninject 2:

Logging infrastructure: Cut because it wasn’t really useful anyway. Ninject doesn’t generate logging messages of its own anymore, but I’m looking into alternative sources of introspection.

...

Ruben Bartelink
thanks, unfortunately I'm looking at Ninject2 which no longer takes a logging module as an argument to StandardKernel's constructor.
chillitom
thanks, I missed that one.. I have just been reading the source though and did notice the lack of any logging.
chillitom
@chillitom: And I was had actually typed in but deleted "Why not look in the source - its not exactly big and it's very readable!" - just as well I retracted that!
Ruben Bartelink
+2  A: 

If you look at the new web site you will see a list of extensions. 2.0 RTM is out and the extensions are being released one at a time, but you can still user them. The logging extension is here and you can track the number with a static object and provide a lambda expression to increment it in .OnActivation(...) during binding.

Ian Davis