温莎城堡(Castle Windsor):注册组件时记录日志的最佳方法? [英] Castle Windsor: Best way to log when a component is registered?
本文介绍了温莎城堡(Castle Windsor):注册组件时记录日志的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想记录何时将组件(接口和实现)注册到我的容器中.最好的方法是什么?
I would like to log when a component (interface and implementation) is registered to my container. What is the best way of doing this?
我发现IKernelEvents接口看起来很有希望,但是我找不到实际使用它的方法.
I found the IKernelEvents interface that looks promising but I can't find how to actually use it.
推荐答案
没关系,发现IKernel实现了IKernelEvents
Nevermind, found that IKernel implements IKernelEvents
因此简单地
WindsorContainer.Kernel.ComponentRegistered += (k, h) => _logger.Debug("Registered {0} - {1}/{2}", k, h.ComponentModel.Service.FullName, h.ComponentModel.Implementation.FullName);
这篇关于温莎城堡(Castle Windsor):注册组件时记录日志的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文