NServiceBus 通用主机和 Common.Logging

发布于 2024-11-05 22:46:00 字数 186 浏览 0 评论 0原文

各位,

我按照此处的说明使 NServiceBus 日志记录正常工作: 但是

,我正在使用 Common .记录。如果我使用 LogManager 进行 Common.Logging,它不会记录日志。

如果我使用 log4net 的 LogManager,一切都会正常。

这里有人有任何见解吗?

Folks,

I got NServiceBus logging working correctly following the directions found here:
http://docs.particular.net/nservicebus/logging/

However, I am using Common.Logging. If I use the LogManager for Common.Logging, it doesn't log.

If I use the LogManager for log4net, everything works just fine.

Anyone have any insight here?

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

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

发布评论

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

评论(3

记忆消瘦 2024-11-12 22:46:00

我明白了这一点。我需要以编程方式设置 Common.Logging,而不是以声明方式(在配置文件中)。

基本上,我在进行流畅的总线配置之前添加了这一行:

    LogManager.Adapter = new Log4NetLoggerFactoryAdapter(new NameValueCollection { { "configType", "INLINE" } });
    SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure);

我的总线日志记录部分如下所示:

.Log4Net<ColoredConsoleAppender>(cca =>
                                                 {
                                                    cca.Layout = patternLayout;
                                                 })
.Log4Net<RollingFileAppender>(fa =>
                                              {
                                                fa.File = "log/handler.log";
                                                fa.AppendToFile = true;
                                                fa.RollingStyle = RollingFileAppender.RollingMode.Size;
                                                fa.MaxSizeRollBackups = 5;
                                                fa.MaximumFileSize = "1000KB";
                                                fa.StaticLogFileName = true;
                                                fa.Layout = patternLayout;
                                              })

这允许我在配置文件中加载日志记录级别,但按照 Udi 的建议将附加程序配置保留在代码中(并且我 我认为这是一个好主意)

我知道我可以使用 nServiceBus 的内置日志记录级别,但我不知道如何对其进行细粒度控制,以便我可以忽略 nHibernate 日志记录,但获取所有 nServiceBus 日志记录。

如果有人需要有关我所做的更多指导,请在此处发表评论,或者如果您知道如何使用 nServiceBus 日志记录级别获得细粒度控制,也请告诉我。

I figured this out. I needed to programatically set up Common.Logging instead of declaratively (in the config file).

Basically, I added this line before I did my fluent bus configuration:

    LogManager.Adapter = new Log4NetLoggerFactoryAdapter(new NameValueCollection { { "configType", "INLINE" } });
    SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure);

And my bus logging section looks like this:

.Log4Net<ColoredConsoleAppender>(cca =>
                                                 {
                                                    cca.Layout = patternLayout;
                                                 })
.Log4Net<RollingFileAppender>(fa =>
                                              {
                                                fa.File = "log/handler.log";
                                                fa.AppendToFile = true;
                                                fa.RollingStyle = RollingFileAppender.RollingMode.Size;
                                                fa.MaxSizeRollBackups = 5;
                                                fa.MaximumFileSize = "1000KB";
                                                fa.StaticLogFileName = true;
                                                fa.Layout = patternLayout;
                                              })

This allows me to load the logging levels in the config file, but leave the appender configuration in code as suggested by Udi (and I think it's a great idea)

I know I could of used the built in logging level of nServiceBus, but I couldn't figure out how to get fine grained control of that so that I could ignore nHibernate logging, but get all of the nServiceBus logging.

If anyone needs more guidance as to what I did, just comment here, or if you know how to get fine grained control using the nServiceBus logging level, let me know that too.

很酷又爱笑 2024-11-12 22:46:00

Common.Logging 作为 log4net 的抽象,用于 NServiceBus 的内部目的。

Common.Logging serves as an abstraction from log4net for the internal purposes of NServiceBus.

池木 2024-11-12 22:46:00

从 NServiceBus 5 开始,支持 OOTB CommonLogging http://docs.pspecial.net/nservicebus/logging /通用日志记录

As of NServiceBus 5 CommonLogging is supported OOTB http://docs.particular.net/nservicebus/logging/common-logging

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