Logger

Logging and Format

Methods for logging a value and configuring the log entry format - type, date format, delimiter, and date-as-attribute behavior.

Methods for logging a value and configuring the log entry format - type, date format, delimiter, and date-as-attribute behavior.

Log is the entry point - it accepts any object and begins the fluent logging chain. WithLogType sets the log level (Info, Warning, Error, Debug, etc.) using the LogType enum. WithLoggingFormat sets the date format pattern for timestamps using the LogDateFormat enum. WithLogDateAsAttribute controls whether the timestamp is embedded as an XML attribute. WithDelimiter sets the character separator when logging in delimited formats. GetFormatString is a static utility that returns the format string for a given LogDateFormat value.

Examples

GPAL Fluent: High-level fluent C# API

//Log accepts any object - strings, numbers, exceptions, or complex objects. GPAL converts the object to a string representation before writing. The logging chain is executed immediately when the terminal method (WithRootDirectory or WithFilename) is reached.

// Basic log call GPAL.Logger .Log("Process started") .WithLogType(LogType.Info) .WithFilename("app.log") .WithRootDirectory("C:\Logs"); // Log an error with timestamp format GPAL.Logger .Log("Unexpected null reference") .WithLogType(LogType.Error) .WithLoggingFormat(LogDateFormat.YearMonthDayHourMinuteSecond) .WithFilename("errors.log") .WithRootDirectory("C:\Logs");