title | description | ms.topic | ms.date |
---|---|---|---|
.NET Aspire Seq component |
Learn how to use the .NET Aspire Seq component to add OpenTelemetry Protocol (OTLP) exporters that send logs and traces to a Seq Server. |
how-to |
06/05/2024 |
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.
To get started with the .NET Aspire Seq component, install the Aspire.Seq NuGet package.
dotnet add package Aspire.Seq
<PackageReference Include="Aspire.Seq"
Version="[SelectVersion]" />
For more information, see dotnet add package or Manage package dependencies in .NET applications.
In the :::no-loc text="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");
To model the Seq resource in the app host, install the Aspire.Hosting.Seq NuGet package.
dotnet add package Aspire.Hosting.Seq
<PackageReference Include="Aspire.Hosting.Seq"
Version="[SelectVersion]" />
In your app host project, register a Seq database and consume the connection using the following methods:
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq")
.ExcludeFromManifest();
var myService = builder.AddProject<Projects.MyService>()
.WithReference(seq);
The preceding code registers a Seq server and propagates its configuration.
Important
You must accept the Seq End User Licence Agreement for Seq to start):
In the :::no-loc text="Program.cs"::: file of the MyService project, configure logging and tracing to Seq using the following code:
builder.AddSeqEndpoint("seq");
Seq shouldn't be part of the .NET Aspire deployment manifest, hence the chained call to ExcludeFromManifest
. It's recommended you set up a secure production Seq server outside of .NET Aspire.
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")
.ExcludeFromManifest();
The directory specified must already exist.
The .NET Aspire Seq component provides options to configure the connection to Seq.
The .NET Aspire Seq component supports xref:Microsoft.Extensions.Configuration?displayProperty=fullName. It loads the SeqSettings
from configuration by using the Aspire:Seq
key. Example :::no-loc text="appsettings.json"::: that configures some of the options:
{
"Aspire": {
"Seq": {
"DisableHealthChecks": true,
"ServerUrl": "http://localhost:5341"
}
}
}
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"
});
[!INCLUDE component-health-checks]
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.
[!INCLUDE component-observability-and-telemetry]
The .NET Aspire Seq component uses the following log categories:
Seq