CSharpEssentials.LoggerHelper is a modular, centralized hub for Serilog sinks that delivers comprehensive observability . Its flexible JSON‑based configuration lets you decide which log levels go to which sink—for example, routing only Error messages to email while sending all logs to ElasticSearch—without touching your code . The package unifies logs, metrics and traces via OpenTelemetry; every log entry carries a trace_id to correlate distributed requests, and an interactive dashboard lets you visualize traces, sink failures and telemetry, and configure alerts . Standard structured fields (e.g., IdTransaction, ApplicationName, MachineName, Action) are included by default, and you can enrich logs with custom properties that propagate across all sinks . Each sink—Console, File, MSSQL, PostgreSQL, ElasticSearch, Email, Telegram, xUnit, Telemetry, Dashboard and AI—is delivered as a separate NuGet package, so you install only what you need; the core loads them dynamically and exposes CurrentError and an in‑memory Errors queue to simplify debugging . The latest AI integration enables natural‑language queries against logs, trace correlation for root‑cause analysis, anomaly detection and automatic incident summaries , while the new xUnit sink captures full traces of failed tests directly in your test output—ideal for debugging flaky tests or disconnected environments
$ dotnet add package CSharpEssentials.LoggerHelper🔌 Modular Architecture
Instead of bundling dozens of sinks into one monolithic library, each sink lives in its own NuGet sub‐package (e.g., CSharpEssentials.LoggerHelper.Sink.File, ...Sink.MSSqlServer, and so on). You install only what you need.
⚡️ Dynamic Sink Loading Our ensures that sinks load “on the fly” at runtime without crashing your app—missing dependencies or version mismatches? No worries. Other sinks continue to work flawlessly.
TolerantPluginLoadContext📄 Centralized Configuration
Manage all your sinks and log‐levels in a single JSON file (appsettings.LoggerHelper.json). Clean, intuitive, and flexible.
🛠️ “CurrentError” Error Tracking
A brand‐new CurrentError static property captures the last exception thrown inside the library. Perfect for production scenarios where you want to expose the most recent failure (for example, inserting it into an HTTP header) :
if (!string.IsNullOrEmpty(loggerExtension<ProviderRequest>.CurrentError))
HttpContext.Response.Headers["loggerExtension.CurrentError"] = loggerExtension<ProviderRequest>.CurrentError;📈 Structured, Level‐Based Routing
Direct logs to one or many sinks based on level (Information, Warning, Error, etc.). You decide what goes where—and it’s easy to change on the fly.
🔀 Infinite Extensibility
Write your own ISinkPlugin implementations, drop them in a folder, and CSharpEssentials.LoggerHelper will discover and register them automatically.
💡 SelfLog Support
Serilog’s internal SelfLog writes to a file you specify so you never miss a diagnostic message if something goes wrong in your logging pipeline.
Version 3.1.1 is a major milestone! Highlights:
Dynamic Loading Revamped
TolerantPluginLoadContext—a custom AssemblyLoadContext that quietly ignores missing dependencies.CurrentError & Full Error List
Exception.Message) that occurred inside LoggerHelper via LoggerExtension<YourContext>.CurrentError.CSharpEssentials.LoggerHelper.Dashboard), so you can see both the single “last” failure and the complete list of errors in one place.Quality‐of‐Life Improvements
NOTE: If you currently reference older versions of Serilog sinks in your project, double‐check the Known Issues section below before upgrading.
CSharpEssentials.LoggerHelper.Sink.ConsoleCSharpEssentials.LoggerHelper.Sink.FileCSharpEssentials.LoggerHelper.Sink.MSSqlServerCSharpEssentials.LoggerHelper.Sink.PostgreSqlCSharpEssentials.LoggerHelper.Sink.ElasticsearchUsed via HttpClientUsed via System.Net.Mail👉 Check out how to use the package in the documentation
📖 View the usage guide here!