如何结合使用Castle Windsor 2.0和Log4Net?

发布于 2024-07-26 01:02:33 字数 781 浏览 5 评论 0 原文

我想使用 Castle Windsor 2.0 作为我的应用程序的控制反转容器,并使用 log4net 1.2.10 来提供日志记录服务。 一些 Google 搜索表明 Windsor 提供了一些日志记录功能,并且我应该在 Windsor 实例化的类上创建一个公共 ILogger 属性。 这听起来很简单,但是我需要在 app.config 中添加什么才能获得使用 log4net 的 ILogger?

我看到的示例似乎来自旧版本的 Castle Windsor,因为它们引用的 DLL 和命名空间不在我下载的发行版中。 特别是,我没有看到包含日志记录对象的 Castle.Facilities.* 命名空间。 其中一些似乎已移至 Castle.Core.Logging?

任何帮助表示赞赏。

更新:

根据下面的答案和进一步的研究,这是我目前的理解。

Castle 项目包版本 1.0 RC3 包含许多不同的组件,包括 MicroKernel、Windsor 和 Services 项目。 我想要的 log4net 集成来自 Services 项目。 因此,如果我要下载 1.0 RC3 软件包,我需要的一切都在一个不错的软件包中。

然而1.0 RC3版本实在是太老了。

从最近一段时间开始,Castle Project 组件仅单独提供。 由于我只下载了 Windsor 2.0,因此我看不到 Services 项目的最新、最好的版本。 此外,服务项目自 1.0 RC3 以来还没有正式发布。 我不确定是否可以只引用 1.0 RC3 版本,还是需要根据最新代码构建自己的版本。

I would like to use Castle Windsor 2.0 as the inversion of control container for my application and log4net 1.2.10 to provide logging services. Some Google searches suggest that Windsor provides some logging facilities and that I am supposed to create a public ILogger property on the classes that Windsor is instantiating. That sounds easy enough, but what do I need to add to app.config so I will get an ILogger that uses log4net?

The examples I have seen seem to come from an older version of Castle Windsor since they reference DLLs and namespaces that are not in the distrubution I downloaded. In particular, I do not see and Castle.Facilities.* namespace that contains logging objects. Some of these seem to have been moved to Castle.Core.Logging?

Any help is appreciated.

UPDATE:

Based on the answers below and further research, here is my current understanding.

Castle Project package release 1.0 RC3 includes many different components, including the MicroKernel, Windsor, and Services projects. The log4net integration I want is from the Services project. So, if I were to download the 1.0 RC3 package, everything I need is in one nice package.

However, the 1.0 RC3 version is really old.

As of some time relatively recently, the Castle Project components are only offered separately. Since I downloaded only the Windsor 2.0, I would not see the latest and greatest version of the Services project. Furthermore, the Services project has not had an official release since 1.0 RC3. I am not sure if I can just reference the 1.0 RC3 version or need to build my own from the latest code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

送舟行 2024-08-02 01:02:33

我相信这也是您所需要的: Where & 温莎城堡如何设置日志记录设施

Here is a exaclty what you need as well I believe: Where & How Castle Windsor sets up logging facility

谁许谁一生繁华 2024-08-02 01:02:33

要使用 Castle Windsor 2.0 的日志记录功能,您必须从 subversion 存储库中提取源代码 (http://svn.castleproject.org:8080/svn/castle/tags/Windsor-2.0)并启动 ClickToBuild.cmd

必要的程序集(Castle.Facilities.Logging.dll、Castle. Services.Logging.Log4netIntegration.dll)可以在 \build\net-3.5\release 中找到。

如果您不想提取源代码并自己构建它,可以转到 http://www.castleproject.org:8090/ 并下载 Windsor 2.x Release 版本的构建工件。

To use the logging facility with Castle Windsor 2.0 you have to pull the source code from the subversion repository (http://svn.castleproject.org:8080/svn/castle/tags/Windsor-2.0) and start ClickToBuild.cmd

The necessary assemblies (Castle.Facilities.Logging.dll, Castle.Services.Logging.Log4netIntegration.dll) can then be found in \build\net-3.5\release

If you do not want to pull the source and build it yourself, you can go to http://www.castleproject.org:8090/ and download the build artifact of the Windsor 2.x Release build.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文