简体   繁体   中英

Castle Windsor: Best way to log when a component is registered?

I would like to log when a component (interface and implementation) is registered to my container. What is the best way of doing this?

I found the IKernelEvents interface that looks promising but I can't find how to actually use it.

Nevermind, found that IKernel implements IKernelEvents

Therefore simply

WindsorContainer.Kernel.ComponentRegistered += (k, h) => _logger.Debug("Registered {0} - {1}/{2}", k, h.ComponentModel.Service.FullName, h.ComponentModel.Implementation.FullName);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM