发送日志到远程MSMQ
我安装了 NLog 版本 2,但发送到远程 MSMQ 不起作用。我的配置设置正确吗?
<nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="MSMQ" name="MSMQLog" useXmlEncoding="true" queue="FormatName:DIRECT=OS:server01\private$\test_log" recoverable="true" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="MSMQLog" />
</rules>
</nlog>
我在本地机器和我发送消息的服务器上安装了 MSMQ。 NLog 不会抛出任何异常(它们已打开)。我在本地计算机上的传出邮箱中没有看到任何内容。
我可以使用以下代码发送到队列。
using (var queue = new MessageQueue(@"FormatName:DIRECT=OS:server01\private$\tasi_log"))
{
var message = new Message("TEST");
message.Formatter = new BinaryMessageFormatter();
queue.Send(message);
}
NLog 可以与远程队列一起使用吗?
I installed NLog version 2 and sending to a remote MSMQ is not working. Do I have the config setup properly?
<nlog autoReload="true" xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target xsi:type="MSMQ" name="MSMQLog" useXmlEncoding="true" queue="FormatName:DIRECT=OS:server01\private$\test_log" recoverable="true" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="MSMQLog" />
</rules>
</nlog>
I installed MSMQ on my local box and the server I'm sending the message too. NLog doesn't throw any exceptions (they are turned on). I don't see anything in the outgoing mailbox on my local machine.
I am able to send to the queue by using the following code.
using (var queue = new MessageQueue(@"FormatName:DIRECT=OS:server01\private$\tasi_log"))
{
var message = new Message("TEST");
message.Formatter = new BinaryMessageFormatter();
queue.Send(message);
}
Does NLog work with remote queues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我尝试发送到公共队列,但使用 NLog 仍然不起作用。于是,我查看了NLog.Extended源代码,发现了这个方法。
我注释掉了以下 if 语句,它现在发送到远程队列。有人可以验证这一点吗?这是一个错误,还是我错过了什么?
So I tried sending to a public queue and it still didn't work using NLog. So, I looked at the NLog.Extended source code and I found this method.
I commented out the following if statement and it now sends to remote queues. Can someone verify this? Is this a bug, or am I missing something?