Logger File
Overview
VersaTul.Logger.File implements the shared logging contract by writing parsed log entries to a rolling flat file.
It combines the base logger abstractions with file-system helpers and an archiving policy so applications can log to disk without handling rotation and file growth manually.
Why Use This Package
Use this package when you want the simplest practical sink for service diagnostics and batch-job visibility.
Its main value is that it gives you a usable rolling file logger without pushing sink-specific logic into application code.
When To Use This Package
Use this package when you want to:
Persist logs locally in text form.
Rotate log files when they reach a configured size.
Enable daily rolling archives and retention cleanup.
Keep the logging sink independent from your application code.
Installation
Install the package with the .NET CLI:
dotnet add package VersaTul.Logger.File
Or with the Package Manager Console:
PM> NuGet\Install-Package VersaTul.Logger.File -Version latest
Start Here If
Local files are a sufficient first logging destination.
You want rotation and retention behavior without writing it yourself.
You are adding operational visibility to a service, scheduler, or import process quickly.
Not The Right First Package If
You only need the shared logging contract and have not chosen a sink yet.
Centralized remote delivery matters more than local visibility.
Works Well With
Logger for the shared logging contract and parser.
Configuration Defaults when you want baseline logging settings.
Logging Setup Workflow when you want the end-to-end setup path first.
Core Types And Concepts
IFileLoggerandFileLoggerFile-backed
ILoggerimplementation.ILogFileConfigurationandLogFileConfigurationExpose file path, file name, max size, rolling, and retention settings.
IArchiverandArchiverHandle log-file rollover and archived file naming.
Key Capabilities
Supports the full sync and async
ILoggercontract.Appends parsed log rows to the configured log file.
Creates the target directory automatically when missing.
Rotates files before append when archiving conditions are met.
Supports daily rolling and retention cleanup through configuration.
Basic Example
using VersaTul.Logger;
using VersaTul.Logger.Contracts;
using VersaTul.Logger.File;
using VersaTul.Logger.File.Contracts;
var configSettings = new Builder()
.AddOrReplace("MaxFileSize", 10_000_000)
.AddOrReplace("LogFileName", "app_log")
.AddOrReplace("FilePath", "C:\\logs")
.BuildConfig();
ILogFileConfiguration configuration = new LogFileConfiguration(configSettings);
ILogParser parser = new LogParser();
IFileHandler fileHandler = new FileUtility(new DirectoryWrapper(), new DirectoryWrapper());
IArchiver archiver = new Archiver(configuration, fileHandler);
ILogger logger = new FileLogger(configuration, archiver, parser, fileHandler);
await logger.LogAsync(new LogInfo(LogLevel.Information, "Startup", "Application started"));
Expected Result
When this package is working well:
the target directory is created automatically,
log entries are written through one shared contract, and
rotation behavior happens through configuration instead of custom code in the application.
Next Step
Read Logging Setup Workflow for the full service-logging workflow.
Read Logger if you want the sink-agnostic contract details behind this implementation.
Compare Logger Mail when alerts should be delivered instead of just stored on disk.
Configuration Notes
ILogFileConfiguration exposes:
MaxFileSizeLogFileNameFilePathFullFilePathFullLogFileNameEnableDailyRollingRetentionDays
Notes
FileLoggerserializes concurrent writes withSemaphoreSlim.Logged rows are written using the parser’s tab format.
This package is a good default sink when local operational visibility matters more than centralized transport.