SyntaxCircus.AspNetCore.Serilog 0.1.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package SyntaxCircus.AspNetCore.Serilog --version 0.1.2
                    
NuGet\Install-Package SyntaxCircus.AspNetCore.Serilog -Version 0.1.2
                    
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="SyntaxCircus.AspNetCore.Serilog" Version="0.1.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SyntaxCircus.AspNetCore.Serilog" Version="0.1.2" />
                    
Directory.Packages.props
<PackageReference Include="SyntaxCircus.AspNetCore.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 SyntaxCircus.AspNetCore.Serilog --version 0.1.2
                    
#r "nuget: SyntaxCircus.AspNetCore.Serilog, 0.1.2"
                    
#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 SyntaxCircus.AspNetCore.Serilog@0.1.2
                    
#: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=SyntaxCircus.AspNetCore.Serilog&version=0.1.2
                    
Install as a Cake Addin
#tool nuget:?package=SyntaxCircus.AspNetCore.Serilog&version=0.1.2
                    
Install as a Cake Tool

SyntaxCircus.AspNetCore.Serilog

Build NuGet License: MIT

A standard Serilog bootstrap for both ASP.NET Core hosts and worker services, with an optional file-sink path resolver. Standalone on purpose — pulled out of SyntaxCircus.AspNetCore.Common so that package stays free of the Serilog dependency for consumers who don't want it.

No support guaranteed. Published as-is and maintained on a best-effort basis. Issues and PRs are welcome, but there's no SLA — fork it or vendor what you need if that's not enough.

Usage

var builder = WebApplication.CreateBuilder(args); // or Host.CreateApplicationBuilder(args) for a worker service
builder.AddStandardSerilog();

var app = builder.Build();
app.UseSerilogRequestLogging(); // ASP.NET Core hosts only

Sets up a console-only bootstrap logger active until the host finishes building, then reconfigures from appsettings/DI services (ReadFrom.Configuration + ReadFrom.Services + Enrich.FromLogContext). Uses Services.AddSerilog(...) rather than Host.UseSerilog(...) so it works on both WebApplicationBuilder and a plain worker-service HostApplicationBuilderAddStandardSerilog targets the shared IHostApplicationBuilder interface both implement.

Optional file logging

builder.AddStandardSerilog(fileLogging =>
{
    fileLogging.Enabled = true;
    fileLogging.Path = "logs/log-.txt"; // optional — relative to content root; omit for the LocalAppData default
    fileLogging.RollingInterval = RollingInterval.Day;
    fileLogging.RetainedFileCountLimit = 14; // optional — omit (default null) to retain all rolled files
});

When Path is omitted, logs go to %LocalAppData%/{ApplicationName}/logs/log-.txt.

RetainedFileCountLimit matches Serilog's own File sink default: null retains every rolled file indefinitely; set it to cap on-disk retention (oldest files beyond the limit are deleted as new ones roll).

Additional enrichers

builder.AddStandardSerilog(configureEnrichment: cfg => cfg
    .Enrich.WithMachineName()
    .Enrich.WithEnvironmentName());

configureEnrichment is invoked after Enrich.FromLogContext() and before the file sink (if any) is wired up — use it to layer on any enrichers AddStandardSerilog doesn't add by default.

Contributing

Issues and pull requests are welcome:

  • Keep changes focused, with a clear description of the behavior change.
  • Match the existing code style (see .editorconfig).
  • Call out any breaking changes to the public API in your PR description.

License

MIT — see LICENSE.txt.

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
0.1.3 653 8/18/2026
0.1.2 102 8/18/2026
0.1.1 115 8/16/2026