Seq.Extensions.Logging
8.0.0
See the version list below for details.
dotnet add package Seq.Extensions.Logging --version 8.0.0
NuGet\Install-Package Seq.Extensions.Logging -Version 8.0.0
<PackageReference Include="Seq.Extensions.Logging" Version="8.0.0" />
paket add Seq.Extensions.Logging --version 8.0.0
#r "nuget: Seq.Extensions.Logging, 8.0.0"
// Install Seq.Extensions.Logging as a Cake Addin #addin nuget:?package=Seq.Extensions.Logging&version=8.0.0 // Install Seq.Extensions.Logging as a Cake Tool #tool nuget:?package=Seq.Extensions.Logging&version=8.0.0
Seq.Extensions.Logging
Seq is a flexible self-hosted back-end for the ASP.NET Core logging subsystem (Microsoft.Extensions.Logging). Log events generated by the framework and application code are sent over HTTP to a Seq server, where the structured data associated with each event is used for powerful filtering, correlation, and analysis.
For an example, see the dotnetconf deep dive session.
This package makes it a one-liner to configure ASP.NET Core logging with Seq.
Getting started
The instructions that follow are for .NET 6.0+ web applications.
Add the NuGet package to your project either by editing the CSPROJ file, or using the NuGet package manager:
dotnet add package Seq.Extensions.Logging
In Program.cs
, call AddSeq()
on the host's ILoggingBuilder
.
// Use the Seq logging configuration in appsettings.json
builder.Host.ConfigureLogging(loggingBuilder =>
loggingBuilder.AddSeq());
The framework will inject ILogger
instances into controllers and other classes:
class HomeController : Controller
{
readonly ILogger<HomeController> _log;
public HomeController(ILogger<HomeController> log)
{
_log = log;
}
public IActionResult Index()
{
_log.LogInformation("Hello, world!");
}
}
Log messages will be sent to Seq in batches and be visible in the Seq user interface. Observe that correlation identifiers added by the framework, like RequestId
, are all exposed and fully-searchable in Seq.
Logging with message templates
Seq supports the templated log messages used by Microsoft.Extensions.Logging. By writing events with named format placeholders, the data attached to the event preserves the individual property values.
var fizz = 3, buzz = 5;
log.LogInformation("The current values are {Fizz} and {Buzz}", fizz, buzz);
This records an event like:
Property | Value |
---|---|
Message |
"The current values are 3 and 5" |
Fizz |
3 |
Buzz |
5 |
Seq makes these properties searchable without additional log parsing. For example, a filter expression like Fizz < 4
would match the event above.
Additional configuration
The AddSeq()
method exposes some basic options for controlling the connection and log volume.
Parameter | Description | Example value |
---|---|---|
apiKey |
A Seq API key to authenticate or tag messages from the logger | "1234567890" |
levelOverrides |
A dictionary mapping logger name prefixes to minimum logging levels | new Dictionary<string,LogLevel>{ ["Microsoft"] = LogLevel.Warning } |
minimumLevel |
The level below which events will be suppressed (the default is Information ) |
LogLevel.Trace |
JSON configuration
The logging level, Seq server URL, API key and other settings can be read from JSON configuration if desired.
In appsettings.json
add a "Seq"
property to "Logging"
to configure the server URL, API key, and levels for the Seq provider:
{
"Logging": {
"LogLevel": {
"Default": "Information"
},
"Seq": {
"ServerUrl": "http://localhost:5341",
"ApiKey": "1234567890",
"LogLevel": {
"System": "Information",
"Microsoft": "Warning"
}
}
}
}
Dynamic log level control
The logging provider will dynamically adjust the default logging level up or down based on the level associated with an API key in Seq. For further information see the Seq documentation.
Including literal JSON strings in log events
The logging provider ships with a JsonSafeString
type that can be used to communicate to the logger that a string contains valid JSON, which can be safely included in a log event as structured data.
var json = "{\"A\": 42}";
_logger.LogInformation("The answer is {Answer}", new JsonSafeString(json));
Trace and span correlation
The Seq logger provider automatically adds trace and span ids to events when present, enabling the Trace drop-down menu in Seq's expanded event view.
ASP.NET Core may add additional top-level TraceId
, SpanId
, and ParentId
properties in its default configuration. You can remove these if you wish, using ILoggingBuilder.Configure()
:
builder.Logging.Configure(opts => {
opts.ActivityTrackingOptions = ActivityTrackingOptions.None;
});
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 SelfLog
.
Add the following line after the logger is configured to print any error information to the console:
Seq.Extensions.Logging.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:
Seq.Extensions.Logging.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
SelfLog
as described above to check for connectivity problems and other issues on the client side. - Raise an issue, ask for help on the Seq support forum or email support@datalust.co.
Versioning policy
The major version of this package tracks the major version of its Microsoft.Extensions.Logging dependency. So, if your
application (on any target runtime) is targeting net6.0
, use the latest 6.* version of this package. Likewise, if
you're targeting net8.0
, target a 8.* version of Seq.Extensions.Logging for the best experience.
Credits
This package is based on a subset of the powerful Serilog library. Not all of the options supported by the Serilog and Seq client libraries are present in the Seq.Extensions.Logging package.
Product | Versions 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 is compatible. 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. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 8.0.0)
-
net6.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 8.0.0)
NuGet packages (18)
Showing the top 5 NuGet packages that depend on Seq.Extensions.Logging:
Package | Downloads |
---|---|
FenixAlliance.ACL.Dependencies
Application Component for the Alliance Business Suite. |
|
GR.Logger
Package Description |
|
ITgenerator.Web
Package Description |
|
Itgenerator.SharedLibrary
Package Description |
|
CodeGame.HostingStartup
Package Description |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on Seq.Extensions.Logging:
Repository | Stars |
---|---|
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/
|
|
andrewlock/asp-dot-net-core-in-action-2e
Source code examples for ASP.NET Core in Action, Second Edition
|
|
andrewlock/asp-dot-net-core-in-action
Source code examples for ASP.NET Core in Action
|
|
andrewlock/asp-dot-net-core-in-action-3e
Source code examples for ASP.NET Core in Action, Third Edition
|
|
v0l/void.cat
Free file hosting website
|
Version | Downloads | Last updated |
---|---|---|
8.0.1-dev-00124 | 1,086 | 8/21/2024 |
8.0.1-dev-00123 | 124 | 8/21/2024 |
8.0.1-dev-00119 | 146 | 8/19/2024 |
8.0.0 | 667,787 | 1/28/2024 |
8.0.0-dev-00115 | 105 | 1/28/2024 |
8.0.0-dev-00113 | 107 | 1/28/2024 |
6.1.0 | 2,072,834 | 8/9/2022 |
6.1.0-dev-00103 | 214 | 8/8/2022 |
6.1.0-dev-00091 | 11,105 | 4/27/2021 |
6.0.2-dev-00090 | 284 | 4/27/2021 |
6.0.0 | 1,973,621 | 1/12/2021 |
6.0.0-dev-00086 | 386 | 1/7/2021 |
5.0.0 | 33,325 | 1/6/2021 |
5.0.0-dev-00080 | 343 | 1/6/2021 |
5.0.0-dev-00067 | 6,897 | 11/26/2019 |
4.0.2 | 386,505 | 11/24/2019 |
4.0.2-dev-00060 | 463 | 11/24/2019 |
4.0.1 | 405,513 | 3/15/2019 |
4.0.1-dev-00056 | 514 | 3/15/2019 |
4.0.0 | 304,844 | 8/24/2017 |
4.0.0-dev-00050 | 869 | 8/23/2017 |
3.0.0 | 4,452 | 8/18/2017 |
3.0.0-dev-00044 | 814 | 8/18/2017 |
3.0.0-dev-00042 | 829 | 8/18/2017 |
2.1.3 | 4,227 | 6/27/2017 |
2.1.3-dev-00037 | 862 | 6/27/2017 |
2.1.2 | 3,600 | 2/15/2017 |
2.1.2-dev-00033 | 917 | 2/15/2017 |
2.1.2-dev-00031 | 975 | 12/2/2016 |
2.1.1 | 2,144 | 11/16/2016 |
2.1.1-dev-00027 | 852 | 11/15/2016 |
2.1.0 | 1,070 | 11/14/2016 |
2.1.0-dev-00022 | 848 | 11/13/2016 |
2.0.1 | 1,430 | 11/4/2016 |
2.0.1-dev-00017 | 1,186 | 11/4/2016 |
2.0.0 | 1,178 | 10/14/2016 |
2.0.0-dev-00013 | 852 | 10/14/2016 |
2.0.0-dev-00012 | 874 | 10/14/2016 |
1.0.1 | 1,120 | 10/4/2016 |
1.0.0 | 2,481 | 9/30/2016 |
1.0.0-dev-00006 | 895 | 10/4/2016 |
1.0.0-dev-00003 | 862 | 9/30/2016 |