简体   繁体   English

使用log4view难以查看/接收nlog网络消息

[英]Difficulty viewing/receiving nlog network messages with log4view

I am trying to get a logging project up and running and having difficulties getting the network logging to work correctly. 我正在尝试启动并运行日志记录项目,并且难以使网络日志记录正常工作。 I've written a simple wrapper for NLog so I can have a project that I just just add to all my other projects. 我为NLog写了一个简单的包装器,所以我可以创建一个项目,我只是添加到我所有的其他项目中。

I have a simple console program for testing this 我有一个简单的控制台程序来测试它

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("Testing Nlog");

        var logger = new Logger("Program");

        int index = 0;
        while (index < 1000)
        {
            Console.WriteLine("Testing Testing 1..2..3..");
            logger.Debug("Testing Testing 1..2..3..");
            index++;
            Thread.Sleep(5000);
        }

        Console.ReadLine();
    }
}

And the following configuration file 以及以下配置文件

<nlog>
  <targets async="true">
    <target name="n4" xsi:type="Network" address="tcp://localhost:877"/>
    <!--<target name="logfile" xsi:type="File" fileName="file.txt" />-->
  </targets>

  <rules>
    <logger name="*" minlevel="Trace" writeTo="n4" />
    <!--<logger name="*" minlevel="Trace" writeTo="logfile" />-->
  </rules>
</nlog>

I've gone into my firewall and opened both udp and tcp 877 ports. 我已经进入防火墙并打开了udp和tcp 877端口。

If I switch the logging to work from file it works fine however when I'm trying to use network logging and using log4view to see the logs I get nothing. 如果我将日志记录从文件切换到工作状态它工作正常,但是当我尝试使用网络日志记录并使用log4view查看日志时,我什么也得不到。 I've tried numerous ipaddresses and hostnames to try and get this to log out. 我尝试了很多ipaddresses和主机名试图让它注销。

I've used log4view before and it seems simple enough to create the tcp or udp receivers so I'm a little at a loss as to what's going wrong. 我之前使用过log4view,它似乎很简单,可以创建tcp或udp接收器,所以我有点不知道出了什么问题。

If anyone can shed some light or see any mistakes I'd be most grateful 如果有人能够解决问题或看到任何错误,我将非常感激

Thanks Neil 谢谢尼尔

而不是使用网络目标我改为使用NLogViewer目标而不是这样做

<target name="log4view" xsi:type="NLogViewer" address="tcp://127.0.0.1:877"/>

I had the same problem. 我有同样的问题。 Being specific about the IP fixed it. 具体关于IP固定它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM