delphimvcframework/lib/loggerpro
2020-09-02 16:13:29 +02:00
..
packages Removed TMVCRESTClient dependencies. (postponed) 2020-09-02 16:13:29 +02:00
clean.bat added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
License.txt added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
loggerpro_logo.png added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LOGGERPRO-BUILD-TIMESTAMP.TXT Updated LoggerPro to v1.3.3 2020-05-14 19:12:52 +02:00
LoggerPro.ConsoleAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.ElasticSearchAppender.pas ISSUE https://github.com/danieleteti/delphimvcframework/issues/205 2019-04-16 23:12:56 +02:00
LoggerPro.EMailAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.FileAppender.pas Removed some hints for old version of Delphi 2019-08-05 12:55:57 +02:00
LoggerPro.GlobalLogger.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.MemoryAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.NSQAppender.pas ISSUE https://github.com/danieleteti/delphimvcframework/issues/205 2019-04-16 23:12:56 +02:00
LoggerPro.OutputDebugStringAppender.pas Updated LoggerPro package 2020-04-27 17:18:16 +02:00
LoggerPro.pas Updated LoggerPro 2020-04-27 23:24:12 +02:00
LoggerPro.Proxy.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.RedisAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.RESTAppender.pas ISSUE https://github.com/danieleteti/delphimvcframework/issues/205 2019-04-16 23:12:56 +02:00
LoggerPro.UDPSyslogAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.Utils.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.VCLListBoxAppender.pas Updated LoggerPro to v1.3.3 2020-05-14 19:12:52 +02:00
LoggerPro.VCLListViewAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
LoggerPro.VCLMemoAppender.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
pasdoc.pds added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
README.md Added support for SQLite in MVCActiveRecord 2019-06-24 21:00:17 +02:00
ThreadSafeQueueU.pas added loggerpro and dmustache as part of the project (no more submodules) 2019-03-06 12:22:35 +01:00
VERSION.TXT Updated LoggerPro to v1.3.3 2020-05-14 19:12:52 +02:00

LoggerPro for Delphi

An modern and pluggable logging framework for Delphi

Compatibility

LoggerPro is compatibile with

  • Delphi XE2
  • Delphi XE3
  • Delphi XE4
  • Delphi XE5
  • Delphi XE6
  • Delphi XE7
  • Delphi XE8
  • Delphi 10 Seattle
  • Delphi 10.1 Berlin
  • Delphi 10.2 Tokyo (Added Linux compatibility)
  • Delphi 10.3 Rio

What's new in 1.3.2

  • Added support for Android API level 26 in mobile demo
  • Added packages for Delphi 10.3 Rio, Delphi 10.2 Tokyo, Delphi 10.1 Berlin and Delphi 10.0 Seattle.
  • Added packages for Delphi XE7 and Delphi XE8 (these packages do not contain appenders which uses System.Net.HttpClient)
  • Added support for Linux in TLoggerProFileAppender (Thank you charoit)

What's new in 1.3.0

  • Replace 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.
  • Improvement to the TLoggerProConsoleAppender (Thanks to Fulgan)
  • Improvement to the TLoggerProFileAppender; now there is a OnLogRow callback that can be used to customize log row format.
  • New overloaded Log methods. The *Fmt versions are deprecated and will be removed in a future version ISSUE #17
  • New NSQ appender (Thanks to Fulgan)
  • New logger filter decorator (Thanks to Fulgan)
  • New REST appender with support for extended information (samples for Windows and Android)
    • Extended information are supported in Windows (fully) and Android (partially)
    • In the sample folder is provided also the RESTLogCollector
  • New Elastic Search Log appender (Thanks to Salvatore Sparacino)

Getting started

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.

Built-in log appenders

The framework contains the following built-in log appenders

  • File appender (TLoggerProFileAppender) (v1.0.0+)
  • Console appender (TLoggerProConsoleAppender) (v1.0.0+)
  • OutputDebugString appender (TLoggerProOutputDebugStringAppender) (v1.0.0+)
  • VCL Memo appender (TVCLMemoLogAppender) (v1.0.0+)
  • VCL ListView appender (TVCLMemoLogAppender) -- thanks to https://github.com/he3p94uu (v1.3.0+)
  • Redis Appender with LogsViewer(to aggregate logs from different instances on a single Redis instance) (v1.2.0+)
  • Email appender (to send email as log, very useful for fatal errors) (v1.2.0+)
  • SysLog appender RFC 5424 compliant -- thanks to https://github.com/nurettin (v1.3.0+)
  • NSQ appender (Thanks to Fulgan) (v1.3.0+)
  • Decorator appender (Thanks to Fulgan) (v1.3.0+)

Next appenders in the development pipeline

  • RESTful Appender (to send logs to a rest endpoint using a specific request format, so that you can implement log server in DelphiMVCFramework, PHP, Java, Python, Node etc)
  • Twitter Appender (to send logs to a Twitter Account)
  • Database appender (to send logs to a database table using FireDAC components -- Thank You Omar Bossoni)

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

Documentation is available in the docs folder as HTML.

Other

You can install Delphinus package manager and install LoggerPro as a package there. (Delphinus-Support)