问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/1167766/castle-windsor-best-way-to-log-when-a-component-is-registered