Have you had any luck getting it to work with the emulator? I am able
to to use the LogFileAppender but when I try to use UDP it fails. I am
just using the sample code in the docs for the udp listener. I am using
vs2003, ppc2003 emulator, loopback adapter. I also have a lan
connection. This is my first attempt at writing udp code. What might I
be doing wrong?
Rob
============== Configuration =========================
<appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
<param name="File" value="Zlog-file.txt" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%m%n" />
</layout>
</appender>
<appender name="MulticastAppender" type="log4net.Appender.UdpAppender" >
<param name="RemoteAddress" value="224.168.100.2" />
<param name="RemotePort" value="11000" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="MulticastAppender" />
</root>
============== Smart Device Application Code ==========
log4net.Config.DOMConfigurator.Configure();
ILog log = LogManager.GetLogger(typeof(Form1));
if (log.IsInfoEnabled) log.Info("TEST...");
log4net.LogManager.Shutdown();
=============== LISTENER ON DESKTOP ===================
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class UDPMulticastListener
{
private static readonly IPAddress GroupAddress =
IPAddress.Parse("224.168.100.2");
private const int GroupPort = 11000;
private static void StartListener()
{
bool done = false;
UdpClient listener = new UdpClient();
IPEndPoint groupEP = new IPEndPoint(GroupAddress,GroupPort);
try
{
listener.JoinMulticastGroup(GroupAddress);
listener.Connect(groupEP);
while (!done)
{
Console.WriteLine("Waiting for broadcast");
byte[] bytes = listener.Receive( ref groupEP);
Console.WriteLine("Received broadcast from {0} :\n {1}\n",
groupEP.ToString(),
Encoding.ASCII.GetString(bytes,0,bytes.Length));
}
listener.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public static int Main(String[] args)
{
StartListener();
return 0;
}
}