Castle Windsor: Best way to log when a component i

2019-04-30 15:54发布

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条回答
Explosion°爆炸
2楼-- · 2019-04-30 16:47

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);
查看更多
登录 后发表回答