Deneblab.ZLoggerExtensions 0.1.11

There is a newer version of this package available.
See the version list below for details.
dotnet add package Deneblab.ZLoggerExtensions --version 0.1.11
                    
NuGet\Install-Package Deneblab.ZLoggerExtensions -Version 0.1.11
                    
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="Deneblab.ZLoggerExtensions" Version="0.1.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Deneblab.ZLoggerExtensions" Version="0.1.11" />
                    
Directory.Packages.props
<PackageReference Include="Deneblab.ZLoggerExtensions" />
                    
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 Deneblab.ZLoggerExtensions --version 0.1.11
                    
#r "nuget: Deneblab.ZLoggerExtensions, 0.1.11"
                    
#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 Deneblab.ZLoggerExtensions@0.1.11
                    
#: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=Deneblab.ZLoggerExtensions&version=0.1.11
                    
Install as a Cake Addin
#tool nuget:?package=Deneblab.ZLoggerExtensions&version=0.1.11
                    
Install as a Cake Tool

ZLogger Extensions

CI/CD NuGet Version License: MIT

Extensions and advanced features for ZLogger, including advanced file logging with archiving, rotation, and enhanced console logging capabilities.

Features

  • 🚀 Advanced File Logger: High-performance file logging with size-based rolling, automatic archiving, and retention policies
  • 🎨 Console Logger with Colors: Enhanced console logging with color support for different log levels
  • 📦 Easy Integration: Seamless integration with .NET's logging infrastructure via ILoggingBuilder
  • ⚙️ Flexible Configuration: Support for both code-based and appsettings.json configuration
  • 🔒 Thread-Safe: All components are thread-safe for multi-threaded applications
  • 🔧 External Process Support: Allow reading/deleting log files during active logging

Installation

Install the package via NuGet Package Manager:

dotnet add package Deneblab.ZLoggerExtensions

Or via Package Manager Console:

Install-Package Deneblab.ZLoggerExtensions

Quick Start

Advanced File Logger

using Microsoft.Extensions.Logging;
using ZLoggerExtensions.AdvanceFileLogger;

var services = new ServiceCollection();
services.AddLogging(builder =>
{
    builder.AddAdvanceFileLogger("logs/app.log");
});

var serviceProvider = services.BuildServiceProvider();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();

logger.LogInformation("Application started");
logger.LogWarning("This is a warning");
logger.LogError("This is an error");

Advanced Configuration

services.AddLogging(builder =>
{
    builder.AddAdvanceFileLogger(options =>
    {
        options.FilePath = "logs/myapp.log";
        options.MaxBytes = 100 * 1024 * 1024; // 100MB
        options.MaxArchivedFiles = 10;
        options.ArchiveDirectory = "archive";
        options.AllowExternalAccess = true;
        options.AutoFlush = true;
    });
});

Configuration via appsettings.json

{
  "Logging": {
    "AdvanceFile": {
      "FilePath": "logs/app.log",
      "MaxBytes": 52428800,
      "MaxArchivedFiles": 7,
      "ArchiveDirectory": "archive",
      "AllowExternalAccess": true,
      "AutoFlush": true
    }
  }
}

Advanced File Logger

The Advanced File Logger provides enterprise-grade file logging capabilities with the following features:

Key Features

  • Size-based Rolling: Configurable file size limit (default: 50MB)
  • Automatic Archiving: Move rolled files to archive subdirectory
  • Retention Policy: Configurable number of archived files to keep (default: 7)
  • External Process Support: Allow reading/deleting log files during logging
  • ZLogger Integration: Full compatibility with ZLogger architecture

Configuration Options

Property Type Default Description
FilePath string "logs/app.log" Base file path for log files
MaxBytes long 50MB File size limit for rolling (0 disables)
MaxArchivedFiles int 7 Maximum archived files to retain
ArchiveDirectory string "archive" Archive directory name
AllowExternalAccess bool true Allow external process file access
AutoFlush bool true Flush after each write
CreateDirectories bool true Create directories if missing
Encoding Encoding UTF8 File encoding
BufferSize int 4096 File buffer size

File Naming Convention

The AdvanceFileLogger follows ZLogger's rolling file naming convention:

  • Current file: app.log
  • Rolled files: app_20231225_143045.log
  • Archived files: archive/app_20231225_143045.log

Console Logger with Colors

Enhanced console logging with color support for different log levels, providing better visual distinction in console applications.

Architecture

The library consists of several well-designed components:

Advanced File Logger Components

  • AdvanceFileLoggerProvider: Main provider implementing ILoggerProvider
  • AdvanceFileWriter: Core file writing with rolling logic
  • FileNameProvider: Handles ZLogger-style file naming
  • FileArchiver: Manages archiving and retention policy
  • AdvanceFileLoggerOptions: Configuration class

Requirements

  • .NET 8.0 or later
  • ZLogger 2.5.10 or later

Dependencies

  • ZLogger: High-performance structured logging library
  • Microsoft.Extensions.Logging: .NET logging abstractions
  • Microsoft.Extensions.DependencyInjection: Dependency injection framework

Performance

The library is designed for high performance:

  • Configurable buffer size for optimal I/O performance
  • Optional auto-flush for immediate persistence
  • Efficient file size monitoring
  • Minimal memory allocation during logging
  • Thread-safe operations without blocking

Error Handling

The logger is designed to be resilient:

  • Failed writes attempt recovery by reopening files
  • Archive failures don't stop logging
  • Invalid configurations are validated at startup
  • Graceful degradation when external processes interfere

Testing

The library includes comprehensive test coverage:

# Run all tests
dotnet test

# Run tests with coverage
dotnet test --collect:"XPlat Code Coverage"

Test coverage includes:

  • Basic logging functionality
  • File rolling behavior
  • Archive retention policy
  • Configuration validation
  • Provider integration
  • External file access scenarios
  • Thread safety verification

Contributing

We welcome contributions! Please see our contributing guidelines for details on how to:

  • Report bugs
  • Suggest enhancements
  • Submit pull requests
  • Follow coding standards

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support


Made with ❤️ by DenebLab

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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
0.1.26 155 10/17/2025
0.1.25 181 10/2/2025
0.1.24 189 9/30/2025
0.1.23 168 9/30/2025
0.1.21 182 9/30/2025
0.1.20 168 9/29/2025
0.1.17 164 9/28/2025
0.1.15 165 9/28/2025
0.1.14 167 9/28/2025
0.1.13 161 9/28/2025
0.1.11 152 9/28/2025
0.1.9 170 9/28/2025