Serilog.Sinks.Seq 9.0.0

dotnet add package Serilog.Sinks.Seq --version 9.0.0
                    
NuGet\Install-Package Serilog.Sinks.Seq -Version 9.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="9.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Serilog.Sinks.Seq" Version="9.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Serilog.Sinks.Seq" />
                    
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.Seq --version 9.0.0
                    
#r "nuget: Serilog.Sinks.Seq, 9.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.
#:package Serilog.Sinks.Seq@9.0.0
                    
#: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.Seq&version=9.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Serilog.Sinks.Seq&version=9.0.0
                    
Install as a Cake Tool

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">

If you would like to see timing and dependency information in Seq, SerilogTracing is a Serilog extension that can send both logs and traces through this sink.

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.  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 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 (426)

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

Package Downloads
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

EtAlii.xTechnology.Diagnostics.Serilog

A package that contains a logging implementation that uses the Serilog logging system.

Convey.Logging

Convey.Logging

GitHub repositories (72)

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

Repository Stars
fullstackhero/dotnet-starter-kit
Production Grade Cloud-Ready .NET 10 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
anjoy8/Blog.Core
💖 ASP.NET Core 8.0 全家桶教程,前后端分离后端接口,vue教程姊妹篇,官方文档:
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.
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
skoruba/IdentityServer4.Admin
The administration for the IdentityServer4 and Asp.Net Core Identity
ChangemakerStudios/Papercut-SMTP
Papercut SMTP -- The Simple Desktop Email Server
vietnam-devs/coolstore-microservices
A full-stack .NET microservices build on Dapr and Tye
AppMetrics/AppMetrics
App Metrics is an open-source and cross-platform .NET library used to record and report metrics within an application.
asynkron/protoactor-dotnet
Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
dotnet-architecture/eShopOnDapr
A sample .NET distributed application based on eShopOnContainers, powered by Dapr.
neozhu/CleanArchitectureWithBlazorServer
This repository is designed to create an enterprise Blazor Server application that follows the principles of Clean Architecture and implements Blazor Clean Architecture best practices for scalability, maintainability, and testability.
desenvolvedor-io/dev-store
A microservices e-commerce reference application built with ASP.NET 9
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
mehdihadeli/food-delivery-microservices
🍔 A practical and cloud-native food delivery microservices, built with .Net Aspire, .Net 9, MassTransit, Domain-Driven Design, CQRS, Vertical Slice Architecture, Event-Driven Architecture, and the latest technologies.
Mimetis/Dotmim.Sync
A brand new database synchronization framework, multi platform, multi databases, developed on top of .Net Standard 2.0. https://dotmimsync.readthedocs.io/
snatch-dev/Convey
A simple recipe for .NET Core microservices.
bing-framework/Bing.NetCore
Bing是基于 .net core 3.1 的框架,旨在提升团队的开发输出能力,由常用公共操作类(工具类、帮助类)、分层架构基类,第三方组件封装,第三方业务接口封装等组成。
davidfowl/Micronetes
Micronetes is a local orchestrator inspired by kubernetes that makes developing and testing microservices and distributed applications easier.
Aguafrommars/TheIdServer
OpenID/Connect, OAuth2, WS-Federation and SAML 2.0 server based on Duende IdentityServer and ITFoxtec Identity SAML 2.0 with its admin UI
Version Downloads Last Updated
9.0.0 9,472,887 12/20/2024
9.0.0-dev-02304 284 12/20/2024
9.0.0-dev-02303 279 12/20/2024
9.0.0-dev-02301 12,022 12/2/2024
9.0.0-dev-00310 32,134 7/21/2024
8.0.1-dev-00309 716 7/21/2024
8.0.0 13,485,409 6/4/2024
8.0.0-dev-00305 692 6/3/2024
8.0.0-dev-00302 645 5/29/2024
8.0.0-dev-00299 4,299 5/8/2024
8.0.0-dev-00297 307 5/8/2024
8.0.0-dev-00295 691 5/7/2024
7.0.1 2,114,995 5/3/2024
7.0.1-dev-00291 283 5/3/2024
7.0.1-dev-00288 5,909 5/1/2024
7.0.1-dev-00286 22,695 4/1/2024
7.0.0 3,065,491 3/6/2024
7.0.0-dev-00282 14,146 2/22/2024
7.0.0-dev-00280 308 2/22/2024
7.0.0-dev-00278 322 2/21/2024
7.0.0-dev-00276 22,784 1/2/2024
6.0.0 7,463,963 11/15/2023
6.0.0-dev-00273 313 11/15/2023
6.0.0-dev-00268 4,507 11/3/2023
6.0.0-dev-00266 10,939 10/5/2023
5.2.3 3,047,868 10/4/2023
5.2.3-dev-00262 217,573 2/5/2023
5.2.3-dev-00260 85,483 11/22/2022
5.2.3-dev-00257 3,672 11/15/2022
5.2.2 16,794,178 11/15/2022
5.2.2-dev-00247 9,657 10/18/2022
5.2.1 2,313,580 9/30/2022
5.2.1-dev-00246 391 10/18/2022
5.2.1-dev-00245 410 10/10/2022
5.2.0 974,203 9/13/2022
5.2.0-dev-00239 412 9/28/2022
5.2.0-dev-00236 435 9/13/2022
5.2.0-dev-00234 990 9/13/2022
5.1.2-dev-00232 431 9/12/2022
5.1.2-dev-00229 1,360 9/12/2022
5.1.2-dev-00225 30,149 6/24/2022
5.1.2-dev-00222 90,508 2/14/2022
5.1.1 15,082,800 1/13/2022
5.1.1-dev-00218 469 1/13/2022
5.1.0 2,759,942 11/12/2021
5.1.0-dev-00214 1,624 11/5/2021
5.1.0-dev-00206 1,288 11/4/2021
5.0.2-dev-00203 589 11/2/2021
5.0.1 9,912,638 4/22/2021
5.0.1-dev-00190 592 4/22/2021
5.0.0 2,472,948 2/11/2021
5.0.0-dev-00184 585 2/11/2021
5.0.0-dev-00174 162,484 2/23/2020
5.0.0-dev-00172 34,816 2/17/2020
4.1.0-dev-00166 526,655 10/17/2019
4.0.1-dev-00159 104,463 9/22/2018
4.0.1-dev-00157 21,147 7/23/2018
4.0.1-dev-00155 20,551 5/9/2018
4.0.1-dev-00154 3,591 4/13/2018
4.0.0 26,505,485 1/14/2018
4.0.0-dev-00150 12,056 10/30/2017
4.0.0-dev-00148 1,960 10/19/2017
3.4.0 1,878,892 9/18/2017
3.4.0-dev-00134 3,677 9/15/2017
3.3.4-dev-00129 5,009 7/27/2017
3.3.4-dev-00126 1,439 7/26/2017
3.3.3 247,904 7/25/2017
3.3.3-dev-00122 1,432 7/25/2017
3.3.2 81,444 6/20/2017
3.3.2-dev-00118 1,456 6/20/2017
3.3.1 74,193 5/22/2017
3.3.1-dev-00114 1,484 5/22/2017
3.3.0 21,215 5/18/2017
3.3.0-dev-00110 4,275 4/8/2017
3.2.0 484,719 1/6/2017
3.2.0-dev-00105 1,523 1/6/2017
3.1.2-dev-00103 1,471 1/6/2017
3.1.2-dev-00100 3,187 11/15/2016
3.1.1 241,445 11/4/2016
3.1.1-dev-00096 1,674 11/4/2016
3.1.0 24,932 11/4/2016
3.1.0-dev-00092 1,791 11/4/2016
3.1.0-dev-00090 1,752 11/3/2016
3.0.2-dev-00088 1,549 10/31/2016
3.0.2-dev-00086 3,346 10/4/2016
3.0.1 182,256 9/9/2016
3.0.1-dev-00082 1,444 9/9/2016
3.0.0 59,906 8/26/2016
3.0.0-dev-00077 1,513 8/26/2016
3.0.0-dev-00076 1,472 8/21/2016
3.0.0-dev-00071 1,553 8/18/2016
3.0.0-dev-00069 5,820 7/7/2016
3.0.0-dev-00067 1,551 7/7/2016
2.0.1 107,675 8/21/2016
2.0.1-dev-00065 1,644 7/5/2016
2.0.0 126,843 6/28/2016
2.0.0-rc-57 2,738 6/20/2016
2.0.0-rc-55 1,669 6/17/2016
2.0.0-rc-51 1,814 6/9/2016
2.0.0-rc-48 2,078 6/1/2016
2.0.0-rc-46 3,138 5/17/2016
2.0.0-beta-42 4,307 3/3/2016
2.0.0-beta-41 1,486 3/3/2016
2.0.0-beta-39 1,445 3/3/2016
2.0.0-beta-38 1,764 2/28/2016
2.0.0-beta-34 2,239 2/23/2016
2.0.0-beta-33 2,029 2/15/2016
2.0.0-beta-32 1,463 2/15/2016
2.0.0-beta-31 1,544 2/9/2016
2.0.0-beta-30 2,207 1/26/2016
2.0.0-beta-29 1,457 1/26/2016
2.0.0-beta-28 1,768 1/14/2016
2.0.0-beta-25 1,851 12/1/2015
2.0.0-beta-23 1,736 11/28/2015
2.0.0-beta-22 1,690 11/28/2015
1.5.36 109,589 2/25/2016
1.5.27 71,411 12/6/2015
1.5.24 9,892 12/1/2015
1.5.17 91,622 9/4/2015
1.5.15 62,136 6/23/2015
1.5.14 24,343 4/30/2015
1.5.11 9,724 4/26/2015
1.5.9 12,045 4/10/2015
1.5.8 8,468 4/10/2015
1.5.7 9,347 4/2/2015
1.5.6 8,652 4/1/2015
1.5.5 9,164 3/26/2015
1.5.4 11,422 3/11/2015
1.5.3 8,463 3/11/2015
1.5.2 8,454 3/11/2015
1.5.1 9,215 3/11/2015
1.4.196 11,997 2/22/2015
1.4.182 10,359 2/15/2015
1.4.168 9,027 2/8/2015
1.4.155 9,252 2/1/2015
1.4.139 11,220 1/23/2015
1.4.118 9,201 1/13/2015
1.4.113 10,021 1/6/2015
1.4.102 10,998 12/21/2014
1.4.99 8,915 12/18/2014
1.4.97 8,705 12/18/2014
1.4.76 11,387 12/8/2014
1.4.39 9,083 11/26/2014
1.4.34 8,799 11/24/2014
1.4.28 8,635 11/24/2014
1.4.27 8,631 11/23/2014
1.4.23 8,638 11/21/2014
1.4.21 8,600 11/21/2014
1.4.18 8,958 11/18/2014
1.4.15 10,854 11/4/2014
1.4.14 8,816 10/23/2014
1.4.13 8,400 10/23/2014
1.4.12 10,315 10/12/2014
1.4.11 8,589 10/8/2014
1.4.10 14,021 9/26/2014
1.4.9 8,749 9/17/2014
1.4.8 8,767 9/11/2014
1.4.7 8,952 9/1/2014
1.4.6 8,426 8/31/2014
1.4.5 8,499 8/27/2014
1.4.4 86,610 8/27/2014