TSLAppLogger 1.0.2
See the version list below for details.
dotnet add package TSLAppLogger --version 1.0.2
NuGet\Install-Package TSLAppLogger -Version 1.0.2
<PackageReference Include="TSLAppLogger" Version="1.0.2" />
<PackageVersion Include="TSLAppLogger" Version="1.0.2" />
<PackageReference Include="TSLAppLogger" />
paket add TSLAppLogger --version 1.0.2
#r "nuget: TSLAppLogger, 1.0.2"
#:package TSLAppLogger@1.0.2
#addin nuget:?package=TSLAppLogger&version=1.0.2
#tool nuget:?package=TSLAppLogger&version=1.0.2
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.OFFdisables 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:
truefor console appsfalsefor 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
โ Recommended Production Configuration
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
TRACEin 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
๐ Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net48 is compatible. net481 was computed. |
-
.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.