Serilog.Sinks.Seq 7.0.0

dotnet add package Serilog.Sinks.Seq --version 7.0.0
NuGet\Install-Package Serilog.Sinks.Seq -Version 7.0.0
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.Seq" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.Seq --version 7.0.0
#r "nuget: Serilog.Sinks.Seq, 7.0.0"
#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.
// Install Serilog.Sinks.Seq as a Cake Addin
#addin nuget:?package=Serilog.Sinks.Seq&version=7.0.0

// Install Serilog.Sinks.Seq as a Cake Tool
#tool nuget:?package=Serilog.Sinks.Seq&version=7.0.0

Serilog.Sinks.Seq Build status NuGet

A Serilog sink that writes events to the Seq structured log server. Supports all modern .NET platforms.

<img alt="Package Logo" src="https://datalust.co/images/seq-nuget.png" width="128px">

Getting started

Install Serilog.Sinks.Seq into your .NET project:

> dotnet add package Serilog.Sinks.Seq

Point the logger to Seq:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Seq("http://localhost:5341")
    .CreateLogger();

And use the Serilog logging methods to associate named properties with log events:

Log.Error("Failed to log on user {ContactId}", contactId);

Then query log event properties like ContactId from the browser:

Query in Seq

When the application shuts down, ensure any buffered events are propertly flushed to Seq by disposing the logger or calling Log.CloseAndFlush():

Log.CloseAndFlush();

The sink can take advantage of Seq's API keys to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the apiKey parameter of WriteTo.Seq().

XML <appSettings> configuration

To adjust the Seq server URL at deployment time, it's often convenient to configure it using XML <appSettings>, in the App.config or Web.config file.

Before Serilog can be configured using XML, the Serilog.Settings.AppSettings package must be installed and enabled using the LoggerConfiguration:

Log.Logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

When XML is used for configuration, it's not necessary to include the WriteTo.Seq() method. It is important however that the Serilog.Sinks.Seq.dll assembly is present alongside the app's binaries.

The settings typically included are:

<configuration>
  <appSettings>
    <add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
    <add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
    <add key="serilog:write-to:Seq.apiKey" value="[optional API key here]" />

Serilog's XML configuration has several other capabilities that are described on the Serilog wiki.

JSON appsettings.json configuration

To use the Seq sink with Microsoft.Extensions.Configuration, for example with ASP.NET Core or .NET Core, use the Serilog.Settings.Configuration package. First install that package if you have not already done so:

dotnet add package Serilog.Settings.Configuration

Instead of configuring the Seq sink directly in code, call ReadFrom.Configuration():

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json")
    .Build();

var logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();

In your appsettings.json file, under the Serilog node, :

{
  "Serilog": {
    "WriteTo": [
      { "Name": "Seq", "Args": { "serverUrl": "http://localhost:5341" } }
    ]
  }
}

See the XML <appSettings> example above for a discussion of available Args options.

Dynamic log level control

The Seq sink can dynamically adjust the logging level up or down based on the level associated with an API key in Seq. To use this feature, create a LoggingLevelSwitch to control the MinimumLevel, and pass this in the controlLevelSwitch parameter of WriteTo.Seq():

var levelSwitch = new LoggingLevelSwitch();

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.ControlledBy(levelSwitch)
    .WriteTo.Seq("http://localhost:5341",
                 apiKey: "yeEZyL3SMcxEKUijBjN",
                 controlLevelSwitch: levelSwitch)
    .CreateLogger();

The equivalent configuration in XML (Serilog 2.6+) is:

<configuration>
  <appSettings>
    
    <add key="serilog:level-switch:$controlSwitch" value="Information" />
    
    <add key="serilog:minimum-level:controlled-by" value="$controlSwitch" />
    <add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
    <add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
    <add key="serilog:write-to:Seq.apiKey" value="yeEZyL3SMcxEKUijBjN" />
    
    <add key="serilog:write-to:Seq.controlLevelSwitch" value="$controlSwitch" />

The equivalent configuration in JSON is:

{
    "Serilog":
    {
        "LevelSwitches": { "$controlSwitch": "Information" },
        "MinimumLevel": { "ControlledBy": "$controlSwitch" },
        "WriteTo":
        [{
            "Name": "Seq",
            "Args":
            {
                "serverUrl": "http://localhost:5341",
                "apiKey": "yeEZyL3SMcxEKUijBjN",
                "controlLevelSwitch": "$controlSwitch"
            }
        }]
    }
}

For further information see the Seq documentation.

Troubleshooting

Nothing showed up, what can I do?

If events don't appear in Seq after pressing the refresh button in the filter bar, either your application was unable to contact the Seq server, or else the Seq server rejected the log events for some reason.

Server-side issues

The Seq server may reject incoming events if they're missing a required API key, if the payload is corrupted somehow, or if the log events are too large to accept.

Server-side issues are diagnosed using the Seq Ingestion Log, which shows the details of any problems detected on the server side. The ingestion log is linked from the Settings > Diagnostics page in the Seq user interface.

Client-side issues

If there's no information in the ingestion log, the application was probably unable to reach the server because of network configuration or connectivity issues. These are reported to the application through Serilog's SelfLog.

Add the following line after the logger is configured to print any error information to the console:

Serilog.Debugging.SelfLog.Enable(Console.Error);

If the console is not available, you can pass a delegate into SelfLog.Enable() that will be called with each error message:

Serilog.Debugging.SelfLog.Enable(message => {
    // Do something with `message`
});
Troubleshooting checklist
  • Check the Seq Ingestion Log, as described in the Server-side issues section above.
  • Turn on the Serilog SelfLog as described above to check for connectivity problems and other issues on the client side.
  • Make sure your application calls Log.CloseAndFlush(), or disposes the root Logger, before it exits - otherwise, buffered events may be lost.
  • If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated "hard" if the close button in the title bar is used, so events buffered for sending to Seq may be lost if you use it.
  • Raise an issue, ask for help on the Seq support forum or email support@datalust.co.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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. 
.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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  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 (304)

Showing the top 5 NuGet packages that depend on Serilog.Sinks.Seq:

Package Downloads
NET6CustomLibrary

open source custom dotnet extension library

Takenet.Iris.Common

Iris common data types package

EtAlii.xTechnology.Diagnostics

A package that contains generic abstractions for debugging and logging purposes.

Hopex.ApplicationServer.SiteModule

Hopex Application site module

MyJetWallet.Sdk.Service

Package Description

GitHub repositories (58)

Showing the top 5 popular GitHub repositories that depend on Serilog.Sinks.Seq:

Repository Stars
dotnet/tye
Tye is a tool that makes developing, testing, and deploying microservices and distributed applications easier. Project Tye includes a local orchestrator to make developing microservices easier and the ability to deploy microservices to Kubernetes with minimal configuration.
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
fullstackhero/dotnet-webapi-starter-kit
production grade .net 8 webapi starter kit with multitenancy support and clean code. 🔥
skoruba/IdentityServer4.Admin
The administration for the IdentityServer4 and Asp.Net Core Identity
Version Downloads Last updated
7.0.0 113,017 3/6/2024
7.0.0-dev-00282 4,606 2/22/2024
7.0.0-dev-00280 76 2/22/2024
7.0.0-dev-00278 83 2/21/2024
7.0.0-dev-00276 6,351 1/2/2024
6.0.0 1,644,729 11/15/2023
6.0.0-dev-00273 113 11/15/2023
6.0.0-dev-00268 2,061 11/3/2023
6.0.0-dev-00266 6,022 10/5/2023
5.2.3 975,286 10/4/2023
5.2.3-dev-00262 168,162 2/5/2023
5.2.3-dev-00260 50,092 11/22/2022
5.2.3-dev-00257 2,913 11/15/2022
5.2.2 9,379,633 11/15/2022
5.2.2-dev-00247 8,372 10/18/2022
5.2.1 1,602,522 9/30/2022
5.2.1-dev-00246 158 10/18/2022
5.2.1-dev-00245 158 10/10/2022
5.2.0 614,452 9/13/2022
5.2.0-dev-00239 153 9/28/2022
5.2.0-dev-00236 167 9/13/2022
5.2.0-dev-00234 713 9/13/2022
5.1.2-dev-00232 172 9/12/2022
5.1.2-dev-00229 554 9/12/2022
5.1.2-dev-00225 24,406 6/24/2022
5.1.2-dev-00222 68,266 2/14/2022
5.1.1 9,640,533 1/13/2022
5.1.1-dev-00218 190 1/13/2022
5.1.0 2,098,545 11/12/2021
5.1.0-dev-00214 1,327 11/5/2021
5.1.0-dev-00206 1,015 11/4/2021
5.0.2-dev-00203 314 11/2/2021
5.0.1 7,798,163 4/22/2021
5.0.1-dev-00190 282 4/22/2021
5.0.0 1,897,782 2/11/2021
5.0.0-dev-00184 306 2/11/2021
5.0.0-dev-00174 144,937 2/23/2020
5.0.0-dev-00172 34,082 2/17/2020
4.1.0-dev-00166 494,375 10/17/2019
4.0.1-dev-00159 95,146 9/22/2018
4.0.1-dev-00157 20,442 7/23/2018
4.0.1-dev-00155 18,523 5/9/2018
4.0.1-dev-00154 2,909 4/13/2018
4.0.0 22,508,861 1/14/2018
4.0.0-dev-00150 10,954 10/30/2017
4.0.0-dev-00148 1,456 10/19/2017
3.4.0 1,440,180 9/18/2017
3.4.0-dev-00134 3,160 9/15/2017
3.3.4-dev-00129 4,476 7/27/2017
3.3.4-dev-00126 939 7/26/2017
3.3.3 216,906 7/25/2017
3.3.3-dev-00122 951 7/25/2017
3.3.2 65,656 6/20/2017
3.3.2-dev-00118 985 6/20/2017
3.3.1 63,639 5/22/2017
3.3.1-dev-00114 975 5/22/2017
3.3.0 13,707 5/18/2017
3.3.0-dev-00110 3,744 4/8/2017
3.2.0 447,684 1/6/2017
3.2.0-dev-00105 1,025 1/6/2017
3.1.2-dev-00103 992 1/6/2017
3.1.2-dev-00100 2,683 11/15/2016
3.1.1 192,623 11/4/2016
3.1.1-dev-00096 1,186 11/4/2016
3.1.0 16,048 11/4/2016
3.1.0-dev-00092 1,279 11/4/2016
3.1.0-dev-00090 1,251 11/3/2016
3.0.2-dev-00088 1,057 10/31/2016
3.0.2-dev-00086 2,847 10/4/2016
3.0.1 156,195 9/9/2016
3.0.1-dev-00082 948 9/9/2016
3.0.0 38,514 8/26/2016
3.0.0-dev-00077 1,002 8/26/2016
3.0.0-dev-00076 1,014 8/21/2016
3.0.0-dev-00071 1,076 8/18/2016
3.0.0-dev-00069 5,308 7/7/2016
3.0.0-dev-00067 1,037 7/7/2016
2.0.1 93,546 8/21/2016
2.0.1-dev-00065 1,137 7/5/2016
2.0.0 112,123 6/28/2016
2.0.0-rc-57 1,887 6/20/2016
2.0.0-rc-55 1,159 6/17/2016
2.0.0-rc-51 1,314 6/9/2016
2.0.0-rc-48 1,578 6/1/2016
2.0.0-rc-46 2,648 5/17/2016
2.0.0-beta-42 3,792 3/3/2016
2.0.0-beta-41 985 3/3/2016
2.0.0-beta-39 963 3/3/2016
2.0.0-beta-38 1,275 2/28/2016
2.0.0-beta-34 1,752 2/23/2016
2.0.0-beta-33 1,529 2/15/2016
2.0.0-beta-32 978 2/15/2016
2.0.0-beta-31 1,053 2/9/2016
2.0.0-beta-30 1,716 1/26/2016
2.0.0-beta-29 962 1/26/2016
2.0.0-beta-28 1,274 1/14/2016
2.0.0-beta-25 1,368 12/1/2015
2.0.0-beta-23 1,235 11/28/2015
2.0.0-beta-22 1,209 11/28/2015
1.5.36 80,214 2/25/2016
1.5.27 47,762 12/6/2015
1.5.24 2,747 12/1/2015
1.5.17 74,684 9/4/2015
1.5.15 53,128 6/23/2015
1.5.14 16,869 4/30/2015
1.5.11 2,600 4/26/2015
1.5.9 4,915 4/10/2015
1.5.8 1,334 4/10/2015
1.5.7 2,158 4/2/2015
1.5.6 1,518 4/1/2015
1.5.5 1,954 3/26/2015
1.5.4 4,030 3/11/2015
1.5.3 1,327 3/11/2015
1.5.2 1,336 3/11/2015
1.5.1 1,896 3/11/2015
1.4.196 4,493 2/22/2015
1.4.182 3,218 2/15/2015
1.4.168 1,884 2/8/2015
1.4.155 2,137 2/1/2015
1.4.139 3,713 1/23/2015
1.4.118 1,983 1/13/2015
1.4.113 2,785 1/6/2015
1.4.102 3,906 12/21/2014
1.4.99 1,784 12/18/2014
1.4.97 1,596 12/18/2014
1.4.76 4,070 12/8/2014
1.4.39 1,940 11/26/2014
1.4.34 1,675 11/24/2014
1.4.28 1,507 11/24/2014
1.4.27 1,527 11/23/2014
1.4.23 1,523 11/21/2014
1.4.21 1,482 11/21/2014
1.4.18 1,792 11/18/2014
1.4.15 3,638 11/4/2014
1.4.14 1,716 10/23/2014
1.4.13 1,324 10/23/2014
1.4.12 3,224 10/12/2014
1.4.11 1,505 10/8/2014
1.4.10 6,902 9/26/2014
1.4.9 1,659 9/17/2014
1.4.8 1,670 9/11/2014
1.4.7 1,845 9/1/2014
1.4.6 1,373 8/31/2014
1.4.5 1,405 8/27/2014
1.4.4 31,199 8/27/2014