Quantcast

Problem with Network target

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problem with Network target

temper
Hi,
I am experiencing the problem with using the Network target on Windows XP Home Edition SP2.
I follow the example mentioned in the "Targets/Network" section with the internal NLog enabled.
My config file (NLog.config):

<?xml version="1.0" encoding="utf-8" ?>
<nlog internalLogFile="Nlog.log" xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <targets>
      <target name="console" xsi:type="Console"
          layout="${message}"/>
      <target name="file" xsi:type="File" fileName="${basedir}/file.txt"
            layout="${message}"/>
      <target name="network" xsi:type="Network" address="udp://127.0.0.1:14141"
            layout="${message}"/>
    </targets>

    <rules>
      <logger name="*" minlevel="Debug" writeTo="console,file,network"/>
    </rules>
</nlog>

My application:
using System;
using System.Collections.Generic;
using System.Text;
using NLog;

namespace TestLogger
{
    class Program
    {
        private static Logger logger = LogManager.GetLogger("Program");
        static void Main(string[] args)
        {
            logger.Debug("Hello");
        }
    }
}

And here is the output of the internal log:

2006-08-16 11:00:22.5312 Info Adding target console:ConsoleTarget
2006-08-16 11:00:22.5468 Info Adding target file:FileTarget
2006-08-16 11:00:22.5468 Info Adding target network:NetworkTarget
2006-08-16 11:00:22.6406 Error Error when sending System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, EndPoint remoteEP)
   at NLog.Internal.NetworkSenders.UdpNetworkSender.DoSend(String text)
   at NLog.Internal.NetworkSenders.NetworkSender.Send(String text)
   at NLog.Targets.NetworkTarget.NetworkSend(String address, String text)
2006-08-16 11:00:22.6406 Error Target exception: System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint remoteEP)
   at System.Net.Sockets.Socket.SendTo(Byte[] buffer, EndPoint remoteEP)
   at NLog.Internal.NetworkSenders.UdpNetworkSender.DoSend(String text)
   at NLog.Internal.NetworkSenders.NetworkSender.Send(String text)
   at NLog.Targets.NetworkTarget.NetworkSend(String address, String text)
   at NLog.Targets.NetworkTarget.Write(LogEventInfo logEvent)
   at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent)
2006-08-16 11:00:24.3437 Info Shutting down logging...
2006-08-16 11:00:24.3437 Info Closing old configuration.
2006-08-16 11:00:24.3437 Info Logger has been shut down.

ANy ideas what is the problem?

I will appreciate any help.

Kind regards,
temper
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

Jarek Kowalski
Administrator
Interesting. I cannot reproduce this here.

What .NET version do you use?
Can you attempt to reproduce this problem on another machine?
Is there anything special about your network stack?

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

temper
Hi,
Thanks for the quick answer. I will indeed investigate the problem on the another machine during the day.
I will let you know about the results.

Kind regards,
temper
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

Jarek Kowalski
Administrator
Can you try to replace src\NLog\Internal\NetworkSenders\UdpNetworkSender.cs with the provided file, recompile NLog and try again?

udpnetworksender.cs

I believe your problem might be related to IPv6 stack installed. Hopefully the provided version fixes this.

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

temper
The new version causes the following compilation errors: c:\Documents and Settings\Marcin\My Documents\Prace\NLog-1.0-RC1\src\NLog\Internal\NetworkSenders\UdpNetworkSender.cs(74,33): error CS0115: 'NLog.Internal.NetworkSenders.UdpNetworkSender.DoSend(byte[])': no suitable method found to override c:\Documents and Settings\Marcin\My Documents\Prace\NLog-1.0-RC1\src\NLog\Internal\NetworkSenders\UdpNetworkSender.cs(44,15): error CS0534: 'NLog.Internal.NetworkSenders.UdpNetworkSender' does not implement inherited abstract member 'NLog.Internal.NetworkSenders.NetworkSender.DoSend(string)' c:\Documents and Settings\Marcin\My Documents\Prace\NLog-1.0-RC1\src\NLog\Internal\NetworkSenders\NetworkSender.cs(128,33): (Related location)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

Jarek Kowalski
Administrator
Download the latest snapshot as a base, then apply the patch and recompile.

http://www.nlog-project.org/snapshots/

Jarek
NLog Blog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problem with Network target

temper
Hi Jarek,
Thanks a lot for help. The patch works!

Kind regards,
temper
Loading...