CordiSharp.Plugins.Serilog
0.2.0
dotnet add package CordiSharp.Plugins.Serilog --version 0.2.0
NuGet\Install-Package CordiSharp.Plugins.Serilog -Version 0.2.0
<PackageReference Include="CordiSharp.Plugins.Serilog" Version="0.2.0" />
<PackageVersion Include="CordiSharp.Plugins.Serilog" Version="0.2.0" />
<PackageReference Include="CordiSharp.Plugins.Serilog" />
paket add CordiSharp.Plugins.Serilog --version 0.2.0
#r "nuget: CordiSharp.Plugins.Serilog, 0.2.0"
#:package CordiSharp.Plugins.Serilog@0.2.0
#addin nuget:?package=CordiSharp.Plugins.Serilog&version=0.2.0
#tool nuget:?package=CordiSharp.Plugins.Serilog&version=0.2.0
CordiSharp.Plugins.Serilog
Integrates Serilog into the CordiSharp log pipeline. CordiSharp's
LoggerService (the ctx.Logger() behind every plugin/fiber) is bridged into a Serilog logger
so it reaches any Serilog WriteTo sink (console, file, Seq, ...), and Serilog LogEvents can be
routed back into the CordiSharp LoggerService buffer.
dotnet add package CordiSharp.Plugins.Serilog
CordiSharp → Serilog (push CordiSharp logs into Serilog sinks)
The primary direction: every LogMessage produced by the CordiSharp pipeline is forwarded to a
Serilog ILogger. The message text is [loggerName] formatted-result.
using CordiSharp.Plugins.Serilog;
using Serilog;
var ctx = Context.Create();
var log = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File("logs/app.log")
.CreateLogger();
// attach the bridge (detaches on dispose)
using var bridge = ctx.UseSerilog(log);
ctx.Logger("chat").Info("hello %s", "world"); // -> [chat] hello world (console/file)
Or load it as a CordiSharp plugin so the bridge follows the plugin fiber lifecycle:
var plugin = await ctx.Plugin(typeof(SerilogPlugin), new SerilogConfig { Logger = log });
// ... later ...
await plugin.DisposeAsync(); // detaches the exporter
Levels
| CordiSharp | Serilog |
|---|---|
Error |
Error |
Warn |
Warning |
Info |
Information |
Debug |
Debug |
Serilog → CordiSharp (route Serilog events into the CordiSharp pipeline)
Register CordiSharpLogSink on a Serilog logger configuration so any Log.Information(...) etc.
lands in the CordiSharp LoggerService (the chosen category becomes the CordiSharp logger name):
using CordiSharp.Plugins.Serilog;
var ctx = Context.Create();
Log.Logger = new LoggerConfiguration()
.WriteTo.CordiSharp(ctx.LoggerService, "serilog")
.WriteTo.Console()
.CreateLogger();
Log.Information("hello {Name}", "world");
// -> ctx.LoggerService.Buffer[0] { Name = "serilog", Level = Info, ... }
Reentrancy
The bridge carries an AsyncLocal echo guard. If you configure both directions at once
(UseSerilog + WriteToCordiSharp), a CordiSharp message exported into Serilog is never routed
back into the same LoggerService, so it cannot loop.
| 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
- CordiSharp (>= 0.2.0)
- Serilog (>= 4.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.