Catalog · How the catalog works
MTLogger
Multi-threaded safe, crossplatform logger for Lazarus/FPC and Delphi.
- ★ 1 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
MTLogger — thread-safe, cross-platform Logger for Lazarus/FPC and Delphi
MTLogger is a thread-safe, cross-platform logger for Lazarus/FPC and Delphi.
It supports asynchronous file logging, real-time log capture, and optional immediate console output.
MTLogger is implemented as a singleton, so no manual initialization is required.
Quickstart
- Download u_logger.pas or install MTLogger using the
boss installcommand:
boss install https://github.com/kompustelnik/MTLogger- Add
u_loggerto theusessection:
uses
u_logger;- (OPTIONALLY) Assign
OnLogEventProc(for global procedures) orOnLogEventObj(e.g. for class methods) to catch logs real-time.
procedure TForm1.FormCreate(Sender: TObject);
begin
MTLogger.OnLogEventObj:= CatchLog;
MTLogger.Log('Starting application.');
end;
procedure TForm1.CatchLog(const AMessage: String);
begin
Memo1.Lines.Add(AMessage);
end;With this setup, any log message generated via Log, LogWarning, or LogError can be captured in real-time.
- Start logging:
- Info log:
MTLogger.Log('Hello, World!');- Warning log:
MTLogger.LogWarning('Settings file modified');- Error log:
MTLogger.LogError('Exception message: ' + E.Message);Logging directly to the console
In console applications, you can print a log message immediately:
WriteLn(MTLogger.Log('Starting application'));Example output:
2026-01-25 22:01:29 - INFO - Starting application.Sample log file
2026-01-25 21:22:29 - INFO - Starting application.
2026-01-25 21:22:37 - INFO - Button 1 pressed
2026-01-25 21:22:38 - INFO - Checkbox 1 checked
2026-01-25 21:22:38 - INFO - Checkbox 2 checked
2026-01-25 21:22:49 - WARNING - Button 2 pressed
2026-01-25 21:22:49 - ERROR - Button 3 pressed
2026-01-25 21:22:50 - INFO - Button 1 pressed
2026-01-25 21:22:50 - INFO - Button 1 pressed
2026-01-25 21:22:51 - INFO - Closing application.Features
- Cross-platform support: Windows, Linux, macOS
- Supports real-time capture via
OnLogEventProc/OnLogEventObj - Can log
INFO,WARNING, andERRORlevels - Safe shutdown, ensuring no log messages are lost
- Optional immediate console output for console apps

