Binsor 和 log4net
我正在使用 Castle Windsor 和 Binsor 在我的应用程序中使用依赖项注入。 我在这两方面都不是专家。 通常我可以弄清楚如何让 Windsor 屈服于我的意愿,但我发现 Binsor 更难,特别是因为我还没有找到任何像样的文档。
我正在尝试创建一个使用日志记录的 binsor 配置文件。 我使用以下 binsor 代码配置日志记录:
facility LoggingFacility:
loggingApi = LoggerImplementation.Log4net
configFile = "ParasiteLogConf.log4net"
这非常有效,所有在容器中注册并且将 ILogger 对象作为构造函数参数的组件都将收到正确的 ILogger 实例。
但是,我现在想做的是为一个特定组件使用另一个记录器。 我希望该组件记录到文件,而其他组件应该只记录到屏幕。 我将如何使用 Binsor 代码来表达这一点?
I'm using Castle Windsor and Binsor to use dependency injection in my application. I'm no expert at either one. Usually I can figure out how to bend Windsor to my will, but I find Binsor much harder, especially since I haven't found any decent documentation for it.
I'm trying to create a binsor configuration file where I use logging. I configure logging using the following binsor code:
facility LoggingFacility:
loggingApi = LoggerImplementation.Log4net
configFile = "ParasiteLogConf.log4net"
This works great, all components that are registered with the container and that takes an ILogger object as an argument to the constructor will receive the correct ILogger instance.
However, what I want to do now is to use another logger for one specific component. I want that component to log to a file, whereas the other components should only log to screen. How would I go about expressing that using Binsor code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Aynede@Rahien 是您的朋友。 他有许多关于使用和配置 Binsor 的博客文章。
对于特殊记录器,您需要将其添加为组件,然后将依赖组件的 logger 属性显式设置为特殊记录器组件的 id。
Aynede@Rahien is your friend here. He has many blog posts on using and configuring Binsor.
For the special logger, you need to add it as a component and then explicitly set the logger property of the dependent component to the id of the special logger component.