Nlog 将日志发送到远程MSMQ

Nlog 将日志发送到远程MSMQ,nlog,Nlog,我安装了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" useXml

我安装了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>

NLog可用于远程队列吗?

因此我尝试发送到公共队列,但使用NLog仍然无法工作。因此,我查看了NLog.Extended源代码,发现了这个方法

protected override void Write(LogEventInfo logEvent) 
        { 
            if (this.Queue == null) 
            { 
                return; 
            } 

            string queue = this.Queue.Render(logEvent); 

            if (!MessageQueue.Exists(queue)) 
            { 
                if (this.CreateQueueIfNotExists) 
                { 
                    MessageQueue.Create(queue); 
                } 
                else 
                { 
                    return; 
                } 
            } 

            using (MessageQueue mq = new MessageQueue(queue)) 
            { 
                Message msg = this.PrepareMessage(logEvent); 
                if (msg != null) 
                { 
                    mq.Send(msg); 
                } 
            } 
        } 
我注释掉了下面的if语句,它现在发送到远程队列。有人能证实这一点吗?这是一个错误,还是我遗漏了什么

if (!MessageQueue.Exists(queue)) 
            { 
                if (this.CreateQueueIfNotExists) 
                { 
                    MessageQueue.Create(queue); 
                } 
                else 
                { 
                    return; 
                } 
            } 
if (!MessageQueue.Exists(queue)) 
            { 
                if (this.CreateQueueIfNotExists) 
                { 
                    MessageQueue.Create(queue); 
                } 
                else 
                { 
                    return; 
                } 
            }