TSLAppLogger 1.0.2

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

TSLAppLogger

TSLAppLogger is a high-performance, asynchronous logging library for
.NET Framework 4.8, designed for telecom, server, and high-throughput applications.

It provides non-blocking logging, file rotation, log retention, and structured logging with minimal runtime overhead.


โœจ Key Features

  • โšก Asynchronous background logging (non-blocking)
  • ๐Ÿ—‚ Automatic file rotation (date & size based)
  • ๐Ÿงน Log retention cleanup
  • ๐Ÿงฉ Structured logging (key-value pairs)
  • ๐Ÿ“„ Optional JSON log format
  • ๐Ÿงต Thread-safe & GC-optimized (object pooling)
  • ๐Ÿ–ฅ Optional console logging
  • ๐ŸŽฏ Optimized for high-throughput & telecom systems
  • ๐Ÿง  C# 7.3 compatible
  • ๐Ÿชต .NET Framework 4.8 supported

๐Ÿ“ฆ Installation

NuGet Package Manager

Install-Package TSLAppLogger

.NET CLI

dotnet add package TSLAppLogger

๐Ÿš€ Quick Start

using TSLAppLogger;

var logger = new Logger("MyClass");
logger.Info("Application started");

Logger.Shutdown();

โš™๏ธ Logger Configuration (IMPORTANT)

Logger.Configure defines global logging behavior and must be called once during application startup (before creating any Logger instances).

Logger.Configure(
    string logRootDirectory = null,
    LogLevel? minimumLogLevel = null,
    bool? enableConsoleLogging = null,
    int? retentionDays = null,
    int? maxFileSizeMB = null,
    int? flushTimeoutMs = null,
    int? bufferSizeKB = null,
    bool? enableJsonLogging = null
);

๐Ÿ”ง Configuration Parameters Explained

logRootDirectory

  • Root directory where log files are written
  • Default: <ApplicationBaseDirectory>/logs
  • Recommended to set explicitly in production
logRootDirectory: @"D:\ApplicationLogs"

minimumLogLevel

  • Minimum severity level that will be logged
  • Default: LogLevel.INFO
  • Messages below this level are ignored
  • LogLevel.OFF disables logging completely
Level Description
TRACE Very detailed diagnostics (dev only)
DEBUG Debugging information
INFO Normal operational messages
WARN Potential problems
ERROR Errors and failures
OFF Disable logging
minimumLogLevel: LogLevel.DEBUG

enableConsoleLogging

  • Enables writing logs to the console
  • Default: Environment.UserInteractive
  • Recommended:
    • true for console apps
    • false for Windows services
enableConsoleLogging: Environment.UserInteractive

retentionDays

  • Number of days logs are retained
  • Old logs are deleted automatically
  • Default: 7
retentionDays: 10

maxFileSizeMB

  • Maximum size of a single log file
  • When exceeded, a new file is created
  • Default: 10 MB
maxFileSizeMB: 12

flushTimeoutMs

  • Maximum time (milliseconds) the background worker waits before flushing logs
  • Default: 1000
  • Lower value โ†’ faster flush, more I/O
  • Higher value โ†’ better throughput, slightly delayed writes
flushTimeoutMs: 1000

bufferSizeKB

  • File stream buffer size
  • Default: 64 KB
  • Increase for very high log volumes
bufferSizeKB: 64

enableJsonLogging

  • Enables JSON-formatted log output
  • Default: false
  • Useful for centralized log ingestion systems
enableJsonLogging: true

using System;
using System.IO;
using TSLAppLogger;

bool isInteractive = Environment.UserInteractive;

Logger.Configure(
    logRootDirectory: Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"),
    minimumLogLevel: LogLevel.INFO,
    enableConsoleLogging: isInteractive,
    retentionDays: 10,
    maxFileSizeMB: 12,
    flushTimeoutMs: 1000,
    bufferSizeKB: 64,
    enableJsonLogging: false
);

๐Ÿงฑ Logger Usage Pattern

One Logger per Class (Best Practice)

private static readonly Logger _log =
    new Logger(nameof(MyService));

๐Ÿ“ Basic Logging

_log.Trace("Trace message");
_log.Debug("Debug message");
_log.Info("Information message");
_log.Warn("Warning message");
_log.Error("Error message");

๐Ÿงฉ Structured Logging

_log.Info(
    "User logged in",
    ("UserId", 1024),
    ("Role", "Admin"),
    ("Source", "UI")
);

๐Ÿท Custom Property Logging

_log.SetCustomProperty(CustomProperty.CallID);
_log.Info(987654, "Incoming call received");

Example output:

[CallID-987654] - Incoming call received

๐Ÿ“„ JSON Logging Example

{
  "ts": "2026-01-09T10:22:14.1234567Z",
  "lvl": "INFO",
  "cls": "MyService",
  "m": "ProcessCall",
  "msg": "Call connected"
}

๐Ÿ“ Log File Structure

Logs/
 โ””โ”€โ”€ 2026_Jan/
     โ”œโ”€โ”€ applog_2026-01-09_10-15-22_12345.log
     โ”œโ”€โ”€ applog_2026-01-09_14-40-02_54321.log
  • Rotation by date and file size
  • Automatic cleanup based on retention policy

๐Ÿ”š Shutdown (CRITICAL)

Always flush logs before application exit:

Logger.Shutdown();

Required for:

  • Console applications
  • Windows services
  • Long-running background processes

โš ๏ธ Best Practices

  • โœ” Call Logger.Configure() once at startup
  • โœ” Use one static logger per class
  • โœ” Prefer structured logging over string concatenation
  • โœ” Avoid TRACE in production
  • โœ” Always call Logger.Shutdown()
  • โŒ Do not log inside tight loops at high verbosity

๐Ÿง  Designed For

  • Telecom systems (TAPI, SIP, call flows)
  • Windows Services
  • High-volume server applications
  • Background workers
  • Long-running console apps

๐Ÿ“œ License

MIT License ยฉ Telesoft Labs Pvt Ltd


Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.

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
3.1.0 117 2/9/2026
3.0.0 113 1/30/2026
2.2.0 110 1/28/2026
2.1.0 111 1/27/2026
2.0.0 104 1/21/2026
1.0.4 108 1/12/2026
1.0.3 109 1/9/2026
1.0.2 106 1/9/2026
1.0.1 112 1/9/2026
1.0.0 107 1/9/2026