Sends logging events as connectionless UDP datagrams to a remote host or a multicast group using an UdpClient.
For a list of all members of this type, see UdpAppender Members.
System.Object
���log4net.Appender.AppenderSkeleton
������log4net.Appender.UdpAppender
���������log4net.Appender.RemoteSyslogAppender
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
UDP guarantees neither that messages arrive, nor that they arrive in the correct order.
To view the logging results, a custom application can be developed that listens for logging events.
When decoding events send via this appender remember to use the same encoding to decode the events as was used to send the events. See the Encoding property to specify the encoding to use.
This example shows how to log receive logging events that are sent on IP address 244.0.0.1 and port 8080 to the console. The event is encoded in the packet as a unicode string and it is decoded as such.
[C#]
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
UdpClient udpClient;
byte[] buffer;
string loggingEvent;
try
{
udpClient = new UdpClient(8080);
while(true)
{
buffer = udpClient.Receive(ref remoteEndPoint);
loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
Console.WriteLine(loggingEvent);
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
[Visual�Basic]
Dim remoteEndPoint as IPEndPoint
Dim udpClient as UdpClient
Dim buffer as Byte()
Dim loggingEvent as String
Try
remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
udpClient = new UdpClient(8080)
While True
buffer = udpClient.Receive(ByRef remoteEndPoint)
loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
Console.WriteLine(loggingEvent)
Wend
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
An example configuration section to log information using this appender to the IP 224.0.0.1 on port 8080:
[XML]
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<remoteAddress value="224.0.0.1" />
<remotePort value="8080" />
<layout type="log4net.Layout.PatternLayout" value="%-5level %logger [%ndc] - %message%newline" />
</appender>
Namespace: log4net.Appender
Assembly: log4net (in log4net.dll)
UdpAppender Members | log4net.Appender Namespace