SyntaxCircus.AspNetCore.Serilog
0.1.3
dotnet add package SyntaxCircus.AspNetCore.Serilog --version 0.1.3
NuGet\Install-Package SyntaxCircus.AspNetCore.Serilog -Version 0.1.3
<PackageReference Include="SyntaxCircus.AspNetCore.Serilog" Version="0.1.3" />
<PackageVersion Include="SyntaxCircus.AspNetCore.Serilog" Version="0.1.3" />
<PackageReference Include="SyntaxCircus.AspNetCore.Serilog" />
paket add SyntaxCircus.AspNetCore.Serilog --version 0.1.3
#r "nuget: SyntaxCircus.AspNetCore.Serilog, 0.1.3"
#:package SyntaxCircus.AspNetCore.Serilog@0.1.3
#addin nuget:?package=SyntaxCircus.AspNetCore.Serilog&version=0.1.3
#tool nuget:?package=SyntaxCircus.AspNetCore.Serilog&version=0.1.3
SyntaxCircus.AspNetCore.Serilog
A standard Serilog bootstrap for ASP.NET Core hosts and worker services, with optional File-sink
configuration. It targets the shared IHostApplicationBuilder interface, so one setup works for
both WebApplicationBuilder and worker-service HostApplicationBuilder.
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.
Install
dotnet add package SyntaxCircus.AspNetCore.Serilog
Quick start
ASP.NET Core
using SyntaxCircus.AspNetCore.Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.AddStandardSerilog();
var app = builder.Build();
app.UseSerilogRequestLogging(); // ASP.NET Core hosts only
Worker service
using Microsoft.Extensions.Hosting;
using SyntaxCircus.AspNetCore.Serilog;
var builder = Host.CreateApplicationBuilder(args);
builder.AddStandardSerilog();
builder.Services.AddHostedService<Worker>();
using var host = builder.Build();
await host.RunAsync();
AddStandardSerilog() installs a console bootstrap logger for pre-DI startup and an independent
full logger for each host. The full logger reads standard Serilog configuration and DI services,
adds LogContext enrichment, and is used through normal ILogger<T> injection.
Static logger boundary:
Serilog.Log.Loggerremains a process-global bootstrap logger. Use DI-providedILogger<T>for a host's fully configured logger. This keeps multiple concurrent hosts, including parallelWebApplicationFactorytests, isolated from Serilog's global reload/freeze lifecycle.
File logging
using Serilog;
builder.AddStandardSerilog(fileLogging =>
{
fileLogging.Enabled = true;
fileLogging.Path = "logs/log-.txt";
fileLogging.RollingInterval = RollingInterval.Day;
fileLogging.RetainedFileCountLimit = 14;
fileLogging.OutputTemplate = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}";
});
File logging is disabled by default. Relative paths are content-root-relative; omitting Path
uses the platform's LocalAppData location under {ApplicationName}/logs/log-.txt.
RetainedFileCountLimit = null retains all rolled files, OutputTemplate = null preserves
Serilog's standard File-sink format, and Shared = false preserves exclusive file access.
Documentation
- Usage guide — complete API reference, configuration behavior, file logging, lifecycle details, multiple-host guidance, and troubleshooting.
- Agent integration guide — decision rules and safe recipes for AI agents modifying consuming applications.
- Repository agent guide — package contracts and contribution/validation guidance for agents working in this repository.
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). - Update the relevant documentation and tests when behavior changes.
- Call out any breaking changes to the public API in your PR description.
License
MIT — see LICENSE.txt.
| 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
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.File (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.