3

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.

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.

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. I've tried numerous ipaddresses and hostnames to try and get this to log out.

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.

If anyone can shed some light or see any mistakes I'd be most grateful

Thanks Neil

2 Answers 2

6

Rather than use a Network target I changed it to use a NLogViewer target instead and this did the trick

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

I had the same problem. Being specific about the IP fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.