Arkanis.Common.Observability.Serilog
1.0.0-dev.1
dotnet add package Arkanis.Common.Observability.Serilog --version 1.0.0-dev.1
NuGet\Install-Package Arkanis.Common.Observability.Serilog -Version 1.0.0-dev.1
<PackageReference Include="Arkanis.Common.Observability.Serilog" Version="1.0.0-dev.1" />
<PackageVersion Include="Arkanis.Common.Observability.Serilog" Version="1.0.0-dev.1" />
<PackageReference Include="Arkanis.Common.Observability.Serilog" />
paket add Arkanis.Common.Observability.Serilog --version 1.0.0-dev.1
#r "nuget: Arkanis.Common.Observability.Serilog, 1.0.0-dev.1"
#:package Arkanis.Common.Observability.Serilog@1.0.0-dev.1
#addin nuget:?package=Arkanis.Common.Observability.Serilog&version=1.0.0-dev.1&prerelease
#tool nuget:?package=Arkanis.Common.Observability.Serilog&version=1.0.0-dev.1&prerelease
Arkanis.Common.Observability.Serilog
Shared Serilog bootstrap and host-registration defaults for Arkanis .NET services and libraries.
This package keeps Serilog-specific runtime setup separate from the provider-neutral Arkanis.Common.Observability package.
Installation
dotnet add package Arkanis.Common.Observability.Serilog
Usage
Create the bootstrap logger before building the host. This captures startup failures before configuration and the IoC container are available.
using Arkanis.Common.Observability.Serilog;
using Microsoft.Extensions.Hosting;
using Serilog;
_ = SerilogBootstrapLogger.UseBootstrapLogger();
try
{
Log.Information("Starting host.");
var builder = Host.CreateApplicationBuilder(args);
_ = builder.AddSerilogDefaults();
using var host = builder.Build();
await host.RunAsync();
}
catch (Exception exception)
{
Log.Fatal(exception, "Host terminated during startup.");
throw;
}
finally
{
await Log.CloseAndFlushAsync();
}
Customize bootstrap logging when startup needs a different minimum level or a caller-provided sink.
_ = SerilogBootstrapLogger.UseBootstrapLogger(options =>
{
options.MinimumLevel = Serilog.Events.LogEventLevel.Debug;
options.UseConsole = true;
});
Customize the final host logger after configuration and services are available.
_ = builder.AddSerilogDefaults(options =>
{
options.ConfigurationSectionName = "Serilog";
options.ConfigureLogger = static (services, logger) =>
{
logger.MinimumLevel.Information();
};
});
Enable Serilog OTLP log export explicitly when the application should send logs to the configured collector endpoint.
The endpoint and protocol are read from OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_PROTOCOL.
The protocol is parsed through Arkanis.Common.Observability.OpenTelemetryProtocolParser.
_ = builder.AddSerilogDefaults(options =>
{
options.OpenTelemetry.Enabled = true;
});
Customize the Serilog OpenTelemetry sink when the application needs resource attributes or headers.
_ = builder.AddSerilogDefaults(options =>
{
options.OpenTelemetry.Enabled = true;
options.OpenTelemetry.ConfigureSink = static (_, sink) =>
{
sink.ResourceAttributes["service.name"] = "example-service";
};
});
Use typed logging property names from Arkanis.Common.Observability when adding constant Serilog properties.
using Arkanis.Common.Observability;
using Arkanis.Common.Observability.Serilog;
using Serilog;
using var logger = new LoggerConfiguration()
.Enrich.WithProperty(new LoggingPropertyName("ApplicationName"), "Example")
.CreateLogger();
Scope
This package configures Serilog for generic host applications.
It does not add ASP.NET Core request logging middleware.
It does not add file, Seq, or OpenTelemetry sinks by default.
OpenTelemetry log export is opt-in and endpoint-driven.
It does not own application-specific telemetry source names, minimum-level overrides, or retention policies.
It does not call Log.CloseAndFlush() for consumers.
Applications should still inject and use Microsoft.Extensions.Logging.ILogger<T> for normal application code.
Serilog remains the provider, enrichment, and sink layer behind the Microsoft logging abstraction.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Arkanis.Common.Observability (>= 1.0.0-dev.1)
- Microsoft.Extensions.Configuration (>= 10.0.9)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.FileProviders.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- Microsoft.Extensions.Primitives (>= 10.0.9)
- OpenTelemetry.Api (>= 1.16.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.16.0)
- Serilog (>= 4.3.1)
- Serilog.Extensions.Hosting (>= 10.0.0)
- Serilog.Settings.Configuration (>= 10.0.1)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.OpenTelemetry (>= 4.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-dev.1 | 48 | 7/9/2026 |