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

霸气de小男生 提交于 2019-12-07 06:51:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!