Apache log4net� SDK Documentation - Microsoft .NET Framework 4.0

UdpAppender Class

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.


public�class�UdpAppender : AppenderSkeleton

Thread Safety

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 and port 8080 to the console. The event is encoded in the packet as a unicode string and it is decoded as such.

IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
UdpClient udpClient;
byte[] buffer;
string loggingEvent;

    udpClient = new UdpClient(8080);
        buffer = udpClient.Receive(ref remoteEndPoint);
        loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
catch(Exception e) 
 Dim remoteEndPoint as IPEndPoint
 Dim udpClient as UdpClient
 Dim buffer as Byte()
 Dim loggingEvent as String
     remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
     udpClient = new UdpClient(8080)

     While True
         buffer = udpClient.Receive(ByRef remoteEndPoint)
         loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
 Catch e As Exception
 End Try

An example configuration section to log information using this appender to the IP on port 8080:

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <remoteAddress value="" />
    <remotePort value="8080" />
    <layout type="log4net.Layout.PatternLayout" value="%-5level %logger [%ndc] - %message%newline" />


Namespace: log4net.Appender

Assembly: log4net (in log4net.dll)

See Also

UdpAppender Members | log4net.Appender Namespace