gpt4 book ai didi

c# - 将 Common.Logging 与 Asp.net MVC 和 CaSTLe Windsor 结合使用

转载 作者:太空狗 更新时间:2023-10-30 00:16:58 26 4
gpt4 key购买 nike

我想使用 Common.Logging 删除对特定日志框架的依赖,但我不确定如何使用 CaSTLe Windsor IoC 容器连接 ILog 接口(interface)。有没有办法做到这一点?谢谢!

最佳答案

你真的想两者都做吗? (使用 Common.Logging 并通过 CaSTLe Windsor IoC 注入(inject)它?)使用 Common.Logging 允许您的应用程序不硬​​依赖特定的日志记录框架(例如 log4net、NLog、Enterprise Logging)。我不使用 CaSTLe,但我的理解是它的日志记录工具具有类似的目标。您可以将 CaSTLe Windsor 配置为使用特定的日志记录框架(例如 log4net 或 NLog),但您的应用程序不需要知道最终使用的是哪个日志记录框架。

通过 CaSTLe Windsor 注入(inject) Common.Logging 就像系上腰带和吊带裤一样!您将通过 CaSTLe Windsor 自己的日志抽象功能注入(inject)日志抽象!

我的猜测是您真的想使用一种技术或另一种技术(Common.Logging 或 CaSTLe Windsor 的日志记录工具)。

如果您真的想通过 CaSTLe Windsor 注入(inject) Common.Logging,您可能会发现此链接很有用:

Logging with Castle.Facilities.Logging and log4net

除其他外,它还描述了如何编写您自己的自定义 CaSTLe Windsor 日志记录工具以供 CaSTLe Windsor 注入(inject)。

关于c# - 将 Common.Logging 与 Asp.net MVC 和 CaSTLe Windsor 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4289163/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com