logging - 温莎城堡 : Best way to log when a component is registered?

标签 logging inversion-of-control castle-windsor

我想记录组件(接口(interface)和实现)何时注册到我的容器。这样做的最佳方法是什么?

我发现 IKernelEvents 接口(interface)看起来很有希望,但我找不到如何实际使用它。

最佳答案

没关系,发现IKernel实现了IKernelEvents

因此简单地说

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

关于logging - 温莎城堡 : Best way to log when a component is registered?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1167766/

相关文章:

asp.net-core - ASP.NET CORE 应用程序的 appsettings.json 中的 Serilog 配置

javascript - Pino 错误日志为空,尽管错误对象包含信息

java - 如何在spring IOC中设置当前beanFactory的父级

dependency-injection - 用户输入依赖注入(inject)的最佳策略是什么?

c# - 使用 CaSTLe Windsor IoC 容器时添加服务初始化方法

c# - 使用 CaSTLe Windsor 为单个接口(interface)注册多个组件

spring-boot - Spring Boot 应用程序意外关闭并记录问题

logging - uWSGI:禁用给定 url 的日志

java - 无法让 Spring 注入(inject)我的依赖项

c# - 无法向 CaSTLe Windsor 注册 MvcMailer