Good, free Delphi logging framework

2019-02-01 08:02发布

can anybody hint me a good, free Delphi logging framework? It should be easy to use and it should support different "log writers" including plain text, database and network.

8条回答
男人必须洒脱
2楼-- · 2019-02-01 08:30

Which logging library is better? mentions the following of which only the last two are free.

查看更多
叛逆
3楼-- · 2019-02-01 08:35

I know it's not free - but well worth it's money: CodeSite by Raize Software. Quality has its price! :-)

I always enjoyed working with CodeSite, especially the ability to add just about any type of objects to the log without huge conversions to a string format was often very helpful.

Again: not free, but worth its price in gold, if you really are serious about production-quality logging and viewing of those logs.

Marc

查看更多
再贱就再见
4楼-- · 2019-02-01 08:36

I have been granted access to update the dormant Log4Delphi project and I have rolled up 4 years of bugfixes and patches into the latest 0.8 release available on Source-forge. I use this library in production and have found it to very stable and reliable and easy to use.

Log4Delphi Downloads Page

查看更多
混吃等死
5楼-- · 2019-02-01 08:36

There is Log4D, another port of the Java Log4J logging framework for Delphi at Sourceforge.

Log4D project page at sourceforge

A description of its architecture can be found on CodeCentral and here.

Help files are available online at http://cc.embarcadero.com/item/16446.

It is currently based on log4j 1.2.12 and quite active, and very easy to use. It includes TLogODSAppender, TLogStreamAppender, TLogFileAppender, TLogRollingFileAppender.

The following example project creates a ODS appender. If you run it in the IDE, the log messages will appear in the ‘Event log’ window.

program Log4Dexample;

{$APPTYPE CONSOLE}

uses
  Log4D,
  SysUtils;

var
  Logger: TLogLogger;

begin
  try
    // basic configuration - creates a TLogODSAppender (ODS = OutputDebugString)
    TLogBasicConfigurator.Configure;

    // set the log level
    TLogLogger.GetRootLogger.Level := Trace;

    // create a named logger
    Logger := TLogLogger.GetLogger('exampleLogger');

    // write log messages
    Logger.Fatal('fatal output');
    Logger.Error('error output');
    Logger.Warn('warn output');
    Logger.Info('info output');
    Logger.Debug('debug output');
    Logger.Trace('trace output');

    ReadLn;

  except
    on E:Exception do
    begin
      Writeln(E.Classname, ': ', E.Message);
      ReadLn;
    end;
  end;
end.

Writing appenders is straightforward, here is an example of a simple console appender:

unit LogConsoleAppender;

interface

uses
  Log4D;

type
  { Send log messages to console output. }
  TLogConsoleAppender = class(TLogCustomAppender)
  protected
    procedure DoAppend(const Message: string); override;
  end;

implementation

{ TLogConsoleAppender }

procedure TLogConsoleAppender.DoAppend(const Message: string);
begin
  if IsConsole then
    Write(Message);
end;

initialization
  RegisterAppender(TLogConsoleAppender);

end.
查看更多
Bombasti
6楼-- · 2019-02-01 08:37

There is another new logging framework for Delphi, which comes in a single file (nxlogging.pas). nxlogging is a nice lightweight and powerful set of classes like log4d (appenders, formaters), but much easier tu use. It includes file appenders (rolling files, all in a single one, etc...) and a tcp appender too, so you can forward your logs to a central logserver.

查看更多
混吃等死
7楼-- · 2019-02-01 08:43

Another alternative to Codesite is Overseer which is open sourced and part of the nexus project, but stands alone so does not require you to use their framework.

查看更多
登录 后发表回答