Arkanis.Common.Observability.Serilog 1.0.0-dev.1

This is a prerelease version of Arkanis.Common.Observability.Serilog.
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
                    
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="Arkanis.Common.Observability.Serilog" Version="1.0.0-dev.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arkanis.Common.Observability.Serilog" Version="1.0.0-dev.1" />
                    
Directory.Packages.props
<PackageReference Include="Arkanis.Common.Observability.Serilog" />
                    
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 Arkanis.Common.Observability.Serilog --version 1.0.0-dev.1
                    
#r "nuget: Arkanis.Common.Observability.Serilog, 1.0.0-dev.1"
                    
#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 Arkanis.Common.Observability.Serilog@1.0.0-dev.1
                    
#: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=Arkanis.Common.Observability.Serilog&version=1.0.0-dev.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Arkanis.Common.Observability.Serilog&version=1.0.0-dev.1&prerelease
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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