开发者

How can I enable logging with Ninject?

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 o开发者_StackOverflow中文版f 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/ninject/ninject


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.


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.

...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜