pvNugsLoggerNc6Hybrid 6.0.0
dotnet add package pvNugsLoggerNc6Hybrid --version 6.0.0
NuGet\Install-Package pvNugsLoggerNc6Hybrid -Version 6.0.0
<PackageReference Include="pvNugsLoggerNc6Hybrid" Version="6.0.0" />
<PackageVersion Include="pvNugsLoggerNc6Hybrid" Version="6.0.0" />
<PackageReference Include="pvNugsLoggerNc6Hybrid" />
paket add pvNugsLoggerNc6Hybrid --version 6.0.0
#r "nuget: pvNugsLoggerNc6Hybrid, 6.0.0"
#:package pvNugsLoggerNc6Hybrid@6.0.0
#addin nuget:?package=pvNugsLoggerNc6Hybrid&version=6.0.0
#tool nuget:?package=pvNugsLoggerNc6Hybrid&version=6.0.0
๐ฆ HybridLoggerService for .NET
A flexible, dependency-injected hybrid logger for .NET applications. The HybridLoggerService aggregates multiple log writers (console, file, SQL, etc.) and routes log messages to all configured destinations. Designed for extensibility, testability, and seamless integration with Microsoft.Extensions.DependencyInjection.
โจ Features
- Aggregate Multiple Log Writers โ Console, file, SQL, and more
- Configurable โ Set minimum log level and writer options via config or code
- Async Logging API โ Non-blocking, scalable logging
- Dependency Injection Ready โ Integrates with .NET DI
- Easily Extensible โ Add custom log writers
๐ฆ Installation
dotnet add package pvNugsLoggerNc6Hybrid
or
Install-Package pvNugsLoggerNc6Hybrid
โก Quick Start
1๏ธโฃ Configure Logging
Add logger settings to your configuration (e.g., appsettings.json):
{
"PvNugsLoggerConfig": {
"MinLogLevel": "trace"
}
}
2๏ธโฃ Register Services
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using pvNugsLoggerNc6Abstractions;
using pvNugsLoggerNc6Hybrid;
var inMemSettings = new Dictionary<string, string>
{
{ "PvNugsLoggerConfig:MinLogLevel", "trace" }
// Add other log writer settings as needed
};
var config = new ConfigurationBuilder()
.AddInMemoryCollection(inMemSettings)
.Build();
var services = new ServiceCollection();
services.TryAddPvNugsHybridLogger(config);
// Register other log writers as needed (console, file, SQL, etc.)
var sp = services.BuildServiceProvider();
var logger = sp.GetRequiredService<ILoggerService>();
3๏ธโฃ Log Messages
await logger.LogAsync("Hello World from HybridLogger!", SeverityEnu.Trace);
๐งช Integration Test Example
A real integration test console using HybridLoggerService with multiple log writers and configuration:
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using pvNugsCsProviderNc6MsSql;
using pvNugsLoggerNc6Abstractions;
using pvNugsLoggerNc6Hybrid;
using pvNugsLoggerNc6MsSql;
using pvNugsLoggerNc6Seri;
Console.WriteLine("Integration console for pvNugsLoggerNc6Hybrid");
var inMemSettings = new Dictionary<string, string>
{
// SERILOG
{ "PvNugsLoggerConfig:MinLogLevel", "trace" },
// CS PROVIDER in Config mode
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Name", "LoggingDb" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Mode", "Config" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Server", "Localhost" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Schema", "dbo" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Database", "IntTestingDb" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:Port", "1433" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:TimeoutInSeconds", "300" },
{ "PvNugsCsProviderMsSqlConfig:Rows:0:UseIntegratedSecurity", "true" },
// MS SQL LOG WRITER CONFIG
{ "PvNugsMsSqlLogWriterConfig:ConnectionStringName", "LoggingDb" },
{ "PvNugsMsSqlLogWriterConfig:DefaultRetentionPeriodForTrace", "00:00:01" },
};
var config = new ConfigurationBuilder()
.AddInMemoryCollection(inMemSettings!)
.Build();
var services = new ServiceCollection();
services.TryAddPvNugsLoggerSeriService(config);
services.TryAddPvNugsCsProviderMsSql(config);
services.TryAddPvNugsMsSqlLogger(config);
services.TryAddPvNugsHybridLogger(config);
var sp = services.BuildServiceProvider();
var cLogger = sp.GetRequiredService<IConsoleLoggerService>();
var hLogger = sp.GetRequiredService<ILoggerService>();
var sLogger = sp.GetRequiredService<IMsSqlLoggerService>();
await cLogger.LogAsync("Logging to both the console and the db ", SeverityEnu.Trace);
await hLogger.LogAsync("Hello World", SeverityEnu.Trace);
await cLogger.LogAsync("Done", SeverityEnu.Trace);
โ๏ธ Configuration
- Configure minimum log level and log writer options via configuration.
- Register any combination of log writers (console, file, SQL, etc.) before calling
TryAddPvNugsHybridLogger. - The hybrid logger will automatically aggregate all registered log writers.
๐๏ธ Architecture
- pvNugsLoggerNc6Abstractions โ Core interfaces and base functionality
- pvNugsLoggerNc6Hybrid โ Hybrid logger (this package)
- pvNugsLoggerNc6Console, pvNugsLoggerNc6MsSql, etc. โ Pluggable log writers
๐งช Testing Support
- Mockable interfaces for unit testing
- Supports integration testing with in-memory or test log writers
๐ License
This project is licensed under the MIT License. See the LICENSE file for details.
For more information, see the source repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.1)
- pvNugsLoggerNc6Abstractions (>= 6.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.0 | 321 | 11/14/2025 |
initial