loggerpro
1.4.1
An modern and pluggable logging framework for Delphi
LoggerPro is compatibile with
ILogItemRenderers
(check samples)System.Net.HttpClient
)TLoggerProFileAppender
(Thank you charoit)TThreadedList<T>
with a custom implementation (TThreadSafeQueue<T>
) because of a bug and this in TMonitor
.
TThreadSafeQueue<T>
is not a drop-in replacement for the TThreadedQueue<T>
but can be used in other projects if you are fighting with the same bug.TVCLMemoLogAppender.Create
gots new parameter: aClearOnStartup
which optionally clear the memo at the startup.TLoggerProConsoleAppender
(Thanks to Fulgan)TLoggerProFileAppender
; now there is a OnLogRow
callback that can be used to customize log row format.Log
methods. The *Fmt
versions are deprecated and will be removed in a future version ISSUE #17RESTLogCollector
program getting_started_console;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
LoggerPro.GlobalLogger; //this is the global logger, it is perfect to understand the basic operation of LoggerPro.
begin
try
//the global logger uses a TLoggerProFileAppender, so your logs will be written on a
//set of files with automatic rolling/rotating
Log.Debug('Debug message', 'main'); //TLoggerProFileAppender uses the "tag" to select a different log file
Log.Info('Info message', 'main');
Log.Warn('Warning message', 'main');
Log.Error('Error message', 'errors');
WriteLn('Check "getting_started_console.00.main.log" and "getting_started_console.00.errors.log" to see your logs');
ReadLn;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
The most flexible/correct approach is not much complicated than the global logger one. Check how is simple to create a custom instance of logwriter
program getting_started_console_appenders;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
LoggerPro, //LoggerPro core
LoggerPro.FileAppender, //File appender
LoggerPro.OutputDebugStringAppender; //OutputDebugString appender
var
Log: ILogWriter;
begin
Log := BuildLogWriter([TLoggerProFileAppender.Create,
TLoggerProOutputDebugStringAppender.Create]);
try
Log.Debug('Debug message', 'main');
Log.Info('Info message', 'main');
Log.Warn('Warning message', 'main');
Log.Error('Error message', 'errors');
WriteLn('Check ');
WriteLn(' "getting_started_console.00.main.log"');
WriteLn(' "getting_started_console.00.errors.log"');
if DebugHook <> 0 then //inform the user where his/her logs are
begin
WriteLn('also, you logs have been sent to the current debugger, check the Delphi''s EventLog window to see them.');
end
else
begin
WriteLn('..seems that no debugger is present. The logs can be seen using DebugView.');
WriteLn('Download it from here https://technet.microsoft.com/en-us/sysinternals/debugview.aspx');
WriteLn('Learn how to use http://tedgustaf.com/blog/2011/5/use-debugview-to-view-debug-output-from-asp-net-web-application/');
end;
ReadLn;
except
on E: Exception do
WriteLn(E.ClassName, ': ', E.Message);
end;
end.
The framework contains the following built-in log appenders
TLoggerProFileAppender
) (v1.0.0+)TLoggerProConsoleAppender
) (v1.0.0+)TLoggerProOutputDebugStringAppender
) (v1.0.0+)TVCLMemoLogAppender
) (v1.0.0+)TVCLMemoLogAppender
) -- thanks to https://github.com/he3p94uu (v1.3.0+)Next appenders in the development pipeline
The log writers and all the appenders are asycnhronous.
Check the samples to see how to use each appender or even combine different appenders.
Documentation is available in the docs
folder as HTML.
You can install Delphinus package manager and install LoggerPro as a package there. (Delphinus-Support)