Logger

Output Configuration

WithRootDirectory sets the base directory for all log files. WithFilename sets a static filename. WithFilenamePattern sets a dynamic naming pattern using the FilenamePattern enum - for example, one file per day or one file per hour. WithDirectoryStructure configures how GPAL organizes files under the root directory (flat, by-date, by-type, etc.) using the DirectoryStructure enum.

Examples

GPAL Fluent: High-level fluent C# API

//WithFilenamePattern and WithFilename are mutually exclusive - use WithFilenamePattern for rotating files and WithFilename for a fixed log file. WithDirectoryStructure(DirectoryStructure.ByDate) creates subdirectories organized by year/month/day.

// Log to a daily rotating file

GPAL.Logger

.Log("Daily report generated")

.WithLogType(LogType.Info)

.WithRootDirectory("C:\AppLogs")

.WithFilenamePattern(FilenamePattern.Daily)

.WithDirectoryStructure(DirectoryStructure.ByDate);


// Log to a fixed filename

GPAL.Logger

.Log("Configuration loaded")

.WithLogType(LogType.Debug)

.WithRootDirectory("C:\AppLogs")

.WithFilename("debug.log");

💬 Ask GPAL