.NET Aspire Seq component
In this article, you learn how to use the .NET Aspire Seq component to add OpenTelemetry Protocol (OTLP) exporters that send logs and traces to a Seq Server. The component supports persistent logs and traces across application restarts via configuration.
Get started
To get started with the .NET Aspire Seq component, install the Aspire.Seq NuGet package.
dotnet add package Aspire.Seq --prerelease
For more information, see dotnet add package or Manage package dependencies in .NET applications.
Example usage
In the Program.cs file of your projects, call the AddSeqEndpoint
extension method to register OpenTelemetry Protocol exporters to send logs and traces to Seq and the .NET Aspire Dashboard. The method takes a connection name parameter.
builder.AddSeqEndpoint("seq");
Configuration
The .NET Aspire Seq component provides options to configure the connection to Seq.
Use configuration providers
The .NET Aspire Seq component supports Microsoft.Extensions.Configuration. It loads the SeqSettings
from configuration by using the Aspire:Seq
key. Example appsettings.json
that configures some of the options:
{
"Aspire": {
"Seq": {
"DisableHealthChecks": true,
"ServerUrl": "http://localhost:5341"
}
}
}
Use inline delegates
You can pass the Action<SeqSettings> configureSettings
delegate to set up some or all the options inline, for example to disable health checks from code:
builder.AddSeqEndpoint("seq", static settings =>
{
settings.DisableHealthChecks = true;
settings.ServerUrl = "http://localhost:5341"
});
AppHost extensions
In your AppHost project, install the Aspire.Hosting.Seq
library with NuGet:
dotnet add package Aspire.Hosting.Seq
Then, in the Program.cs file of the .AppHost project, register a Seq server and propagate its configuration using the following methods (note that you must accept the Seq End User Licence Agreement for Seq to start):
var seq = builder.AddSeq("seq");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(seq);
In the Program.cs file of the MyService project, configure logging and tracing to Seq using the following code:
builder.AddSeqEndpoint("seq");
Persistent logs and traces
Register Seq with a data directory in your AppHost project to retain Seq's data and configuration across application restarts.
var seq = builder.AddSeq("seq", seqDataDirectory: "./seqdata");
The directory specified must already exist.
Seq in the .NET Aspire manifest
Seq isn't part of the .NET Aspire deployment manifest. It's recommended you set up a secure production Seq server outside of .NET Aspire.
Health checks
By default, .NET Aspire components enable health checks for all services. For more information, see .NET Aspire components overview.
The .NET Aspire Seq component handles the following:
- Integrates with the
/health
HTTP endpoint, which specifies all registered health checks must pass for app to be considered ready to accept traffic.
Observability and telemetry
.NET Aspire components automatically set up Logging, Tracing, and Metrics configurations, which are sometimes known as the pillars of observability. For more information about component observability and telemetry, see .NET Aspire components overview. Depending on the backing service, some components may only support some of these features. For example, some components support logging and tracing, but not metrics. Telemetry features can also be disabled using the techniques presented in the Configuration section.
Logging
The .NET Aspire Seq component uses the following log categories:
Seq
See also
.NET Aspire
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for