/// <summary> /// Adds a sink that sends log events as UDP packages over the network. /// </summary> /// <param name="sinkConfiguration">Logger sink configuration.</param> /// <param name="remoteAddress"> /// The <see cref="IPAddress"/> of the remote host or multicast group to which the UDP /// client should sent the logging event. /// </param> /// <param name="remotePort"> /// The TCP port of the remote host or multicast group to which the UDP client should sent /// the logging event. /// </param> /// <param name="formatter"> /// Controls the rendering of log events into text, for example to log JSON. To control /// plain text formatting, use the overload that accepts an output template. /// </param> /// <param name="localPort"> /// The TCP port from which the UDP client will communicate. The default is 0 and will /// cause the UDP client not to bind to a local port. /// </param> /// <param name="restrictedToMinimumLevel"> /// The minimum level for events passed through the sink. The default is /// <see cref="LevelAlias.Minimum"/>. /// </param> /// <returns>Logger configuration, allowing configuration to continue.</returns> public static LoggerConfiguration Udp( this LoggerSinkConfiguration sinkConfiguration, IPAddress remoteAddress, int remotePort, ITextFormatter formatter, int localPort = 0, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum) { if (sinkConfiguration == null) { throw new ArgumentNullException(nameof(sinkConfiguration)); } var client = new UdpClientWrapper(localPort, remoteAddress); var sink = new UdpSink(client, remoteAddress, remotePort, formatter); return(sinkConfiguration.Sink(sink, restrictedToMinimumLevel)); }