pvNugsLoggerNc9 9.1.1

dotnet add package pvNugsLoggerNc9 --version 9.1.1
                    
NuGet\Install-Package pvNugsLoggerNc9 -Version 9.1.1
                    
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="pvNugsLoggerNc9" Version="9.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="pvNugsLoggerNc9" Version="9.1.1" />
                    
Directory.Packages.props
<PackageReference Include="pvNugsLoggerNc9" />
                    
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 pvNugsLoggerNc9 --version 9.1.1
                    
#r "nuget: pvNugsLoggerNc9, 9.1.1"
                    
#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 pvNugsLoggerNc9@9.1.1
                    
#: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=pvNugsLoggerNc9&version=9.1.1
                    
Install as a Cake Addin
#tool nuget:?package=pvNugsLoggerNc9&version=9.1.1
                    
Install as a Cake Tool

pvNugsLoggerNc9

A comprehensive .NET logging solution providing flexible, structured logging with support for multiple outputs and contextual information.

Features

  • Multiple logging destinations (Console, SQL, Hybrid) with a unified interface
  • Contextual logging with user and company information
  • Topic-based log organization
  • Automatic caller information capture (method name, file path, line number)
  • Async and sync logging methods
  • Exception handling with detailed stack traces
  • Severity level filtering
  • Integration with Microsoft.Extensions.Logging
  • Full support for dependency injection

Installation

Install via NuGet Package Manager:

bash
dotnet add package pvNugsLoggerNc9

Or via Package Manager Console:

powershell
Install-Package pvNugsLoggerNc9

Quick Start

csharp
// Register services in your DI container
services.AddConsoleLogger(); // For console logging
// or
services.AddSqlLogger(connectionString); // For SQL logging
// or
services.AddHybridLogger(); // For multiple outputs

// Inject and use in your code
public class MyService
{
private readonly ILoggerService _logger;

    public MyService(ILoggerService logger)
    {
        _logger = logger;
    }

    public void DoSomething()
    {
        // Set context
        _logger.SetUser("userId", "companyId");
        _logger.SetTopic("Operations");

        // Log messages
        _logger.Log("Operation started", SeverityEnu.Info);

        try
        {
            // Your code here
        }
        catch (Exception ex)
        {
            _logger.Log(ex); // Automatically includes stack trace
        }
    }
}

Logger Types

Console Logger

Outputs logs to the console with formatted messages and color-coding based on severity.

SQL Logger

Stores logs in a SQL database with structured data for efficient querying and analysis.

Hybrid Logger

Combines multiple logging destinations for simultaneous output to different targets.

Advanced Features

Topic-based Logging

csharp
_logger.SetTopic("UserManagement");
_logger.Log("User profile updated", SeverityEnu.Info);

Async Logging

csharp
await _logger.LogAsync("Async operation completed", SeverityEnu.Debug);

Batch Message Logging

csharp
var messages = new[] { "Step 1", "Step 2", "Step 3" };
_logger.Log(messages, SeverityEnu.Info);

Method Result Logging

csharp
var result = await operation.ExecuteAsync();
_logger.Log(result); // Logs result status and any notifications

Configuration

Minimum Log Level

csharp
services.Configure<PvNugsLoggerConfig>(config =>
{
config.MinLogLevel = "Debug"; // Trace, Debug, Info, Warning, Error, Fatal
});

Multiple Outputs

csharp
services.AddHybridLogger(config =>
{
config.AddConsoleOutput()
.AddSqlOutput(connectionString);
});

Dependencies

  • .NET 9.0+
  • Microsoft.Extensions.Logging.Abstractions

License

MIT License

Author

Pierre Van Wallendael

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
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
9.1.1 276 9/17/2025
9.1.0 142 9/10/2025
9.0.1 188 8/27/2025
9.0.0 189 8/27/2025

aligned with abstraction version 9.1.1