Serilog.Sinks.Udp 10.0.1

dotnet add package Serilog.Sinks.Udp --version 10.0.1
                    
NuGet\Install-Package Serilog.Sinks.Udp -Version 10.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.Udp" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Serilog.Sinks.Udp" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Serilog.Sinks.Udp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Serilog.Sinks.Udp --version 10.0.1
                    
#r "nuget: Serilog.Sinks.Udp, 10.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Serilog.Sinks.Udp@10.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Serilog.Sinks.Udp&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.Udp&version=10.0.1
                    
Install as a Cake Tool

Serilog.Sinks.Udp - A Serilog sink sending UDP packages over the network

CI/CD codecov NuGet Version SemVer compatible NuGet Documentation Join the chat at https://gitter.im/serilog/serilog Help

Package - Serilog.Sinks.Udp | Platforms - .NET Framework 4.6.2, .NET Standard 2.0/2.1

Table of contents


Super simple to use

In the following example, the sink will send UDP packages on the network to localhost on port 7071.

Serilog.ILogger log = new LoggerConfiguration()
  .MinimumLevel.Verbose()
  .WriteTo.Udp("localhost", 7071, AddressFamily.InterNetwork)
  .CreateLogger();

Used in conjunction with Serilog.Settings.Configuration the sink can be configured in appsettings.json.

{
  "Serilog": {
    "MinimumLevel": "Verbose",
    "WriteTo": [
      {
        "Name": "Udp",
        "Args": {
          "remoteAddress": "localhost",
          "remotePort": 7071,
          "family": "InterNetwork"
        }
      }
    ]
  }
}

Used in conjunction with Serilog.Settings.AppSettings the sink can be configured in XML <appSettings>.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="serilog:minimum-level" value="Verbose" />
    <add key="serilog:using:Udp" value="Serilog.Sinks.Udp" />
    <add key="serilog:write-to:Udp" />
    <add key="serilog:write-to:Udp.remoteAddress" value="localhost" />
    <add key="serilog:write-to:Udp.remotePort" value="7071" />
    <add key="serilog:write-to:Udp.family" value="InterNetwork" />
  </appSettings>
</configuration>

Typical use case

Producing log events is only half the story. Unless you are consuming them in a matter that benefits you in development or production, there is really no need to produce them in the first place.

In development I've been sending UDP packages to the loopback address, and used Log2Console to visualize them. It supports UDP receivers, and allows me to filter and search according to my needs.

Taking it to the next level is when you as a team agree on sending the log events to a multicast address, making them accessible to all team members. This can be beneficial for Quality Assurance who wishes to monitor log events from all instances of your running application.

Event formatters

The event formatter is an output template on steroids. It has the responsibility of turning a single log event into a textual representation. It can serialize the log event into JSON, XML or anything else that matches the expectations of the receiver.

The sink comes pre-loaded with two XML based event formatters. One is matching the log4j schema expected by Log2Console and the other is matching the log4net schema expected by Log4View.

Log4jTextFormatter

The log event is formatted according to the log4j XML schema expected by Log2Console.

<log4j:event logger="Some.Serilog.Context" timestamp="1184286222308" level="ERROR" thread="1">
  <log4j:message>Something failed</log4j:message>
  <log4j:throwable>An exception describing the failure<log4j:throwable>
</log4j:event>

Log4netTextFormatter

The log event is formatted according to the log4net XML schema expected by Log4View.

<log4net:event logger="Some.Serilog.Context" timestamp="2017-09-01T22:00:00.000+02:00" level="DEBUG" thread="1" username="MACHINE\username" domain="dotnet">
  <log4net:locationInfo class="Some.Serilog.Context" method="System.String Get(Int32)"/>
  <log4net:properties>
    <log4net:data name="log4net:HostName" value="MACHINE"/>
  </log4net:properties>
  <log4net:message>Something went wrong.</log4net:message>
  <log4net:throwable>System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.</log4net:throwable>
</log4net:event>

Sample applications

The following sample applications demonstrate the usage of this sink in various contexts:

Install via NuGet

If you want to include the UDP sink in your project, you can install it directly from NuGet.

To install the sink, run the following command in the Package Manager Console:

PM> Install-Package Serilog.Sinks.Udp

Donations

If this project has helped you to stay productive and save money, you can buy me a cup of coffee 😃

PayPal Donate

Credit

Thank you JetBrains for your important initiative to support the open source community with free licenses to your products.

JetBrains

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Serilog.Sinks.Udp:

Package Downloads
MTD.BM.Common

此模块为MTD系统基础模块,包含多个组件

GL

Package Description

CnWeb.Top.Logging

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 501 1/3/2026
10.0.0 592,398 4/3/2024
10.0.0-beta.1 158 4/3/2024
9.0.0 265,074 10/19/2023
9.0.0-beta.2 3,128 6/1/2023
8.0.1 924,431 11/20/2022
8.0.0 160,721 3/26/2022
7.1.0 494,369 10/19/2020
7.0.1 23,943 8/14/2020
7.0.0 1,000,553 3/9/2020
6.0.0 323,045 7/8/2019
6.0.0-beta4 1,198 7/7/2019
6.0.0-beta3 1,172 6/30/2019
6.0.0-beta2 4,266 3/29/2019
6.0.0-beta1-6.0.0-beta1-00689 11,746 3/27/2019
5.0.1 132,914 1/6/2019
5.0.0 14,381 9/13/2018
4.1.0 563,084 6/6/2018
4.1.0-release-4-1-0-beta-1-... 1,921 6/1/2018
4.0.1 56,644 1/29/2018
4.0.0 42,003 11/9/2017
3.3.0 14,725 9/13/2017
3.3.0-beta-1-00507 1,708 9/13/2017
3.2.0 4,881 8/26/2017
3.1.0 4,128 8/20/2017
3.0.0 10,951 5/2/2017
2.3.1 2,756 4/24/2017
2.3.0 13,307 4/14/2017
2.3.0-beta2 1,699 4/13/2017
2.3.0-beta1 1,711 4/13/2017
2.2.0 19,842 3/16/2017
2.2.0-beta-00203 1,988 3/16/2017
2.1.0 115,304 11/1/2016
2.0.0 3,044 10/31/2016
1.1.0 119,507 1/19/2016
1.0.1 3,040 3/30/2015
1.0.0 3,089 3/26/2015

For release notes, please see the change log on GitHub.