Good, free Delphi logging framework
Asked Answered
S

8

24

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.

Selftaught answered 27/7, 2009 at 8:1 Comment(1)
Can't make a coment here... Telling from names, Log4delphi and Log4D are both inspired and modelled after Log4J Then how they are different and how to choose between ?Decretal
A
13

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

Angulo answered 27/7, 2009 at 10:51 Comment(2)
@Kenny being open source, Log4D development can be continued any time by others. Also, the Log4Delphi listed here is a different project.Ache
QuickLogger is uptodate and logs to Redis, Elastic, Influxdb, files, email, etc... github.com/exilon/QuickLoggerPoultryman
S
8

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

Shapely answered 27/7, 2009 at 8:38 Comment(7)
I have to disagree with this, although my opinion is of course very biased, as I'm one of the developers behind the SmartInspect logging tool. One of the many reasons CodeSite is almost never the best solution is because you have to distribute an external Dispatcher service with your application in order to log data (yes, there are *Direct protocols for CodeSite now, but they are very limited and slow). There are other reasons against CodeSite, but it's one of the main reasons users switch to other tools in my experience.Malign
I see your point on the Dispatcher service - that could be a drawback depending on your scenario. What other reasons would you have, though?Shapely
marc_s: Sorry about the downvote, I agree it wasn't the best way to communicate my disagreement with your statement (I've removed the downvote), and it wasn't meant personal.Malign
You asked about other reasons/issues: based on reports from customers who switched to SmartInspect, one big issue with CodeSite seems to be the slow logging performance. Another issue: the default logging protocol is based on window messages, which is very problematic for quite a few applications, especially since Windows Vista changed the service/desktop interaction mechanisms. Others: lack of asynchronous logging, log levels, file encryption etc. Of course, some of these issues might not be a problem in all scenarios. I'm just saying that there are better tools, not even necessarily our own.Malign
OK, thanks - bringing up your reservations about CodeSite in this manner is much more productive and hopefully also more helpful to the original poster than a downvote - thanks!Shapely
@Dennis: a central dispatcher (or other TCP/IP logging server) like the one in CodeSite is very useful - or should I say required - if many applications from different workstations or a Terminal Server farm must write to the same log file. Which other logging tool do you know which can handle this? (just curious)Ache
@Ache SmartInspect has an optional router service that does exactly this. However, this is a very special use case (even if it's an important one) and although I believe a good logging tool should support this, it shouldn't be the default/only way of processing log entries (because in most cases, especially when you need logging in environments that you cannot control, installing a separate application just for logging is just not practical).Malign
Y
6

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

Yuonneyup answered 12/11, 2010 at 13:52 Comment(1)
Kenny, As with many Delphi frameworks out there support and maintenance is starting to wain as people stop using Delphi. There was a guy who made a clone of Log4Delphi and was keeping it up to date but I can't seem to fine his page anymore.Yuonneyup
P
6

A logger library shouldn't dump the contents synchronously. That will slow down the application. Instead, it needs to buffer the contents and dump them when it is flushed.

It should also be thread-safe and able to dump the contents from different threads. (And preferably be able to log the thread ID as well)

It should also be flexible and able to log multiple output formats.

Here's a library which does all this: loggerpro

Principalities answered 22/10, 2017 at 5:48 Comment(4)
It's great, it's by the same author of the Delphi MVC framework, I especially like the "memory appender", and I adopted to TSynLog in the mORMot framework.Hix
@EdwinYip I recently added a syslog appender to loggerpro, they make it very easy to contribute.Principalities
thanks for letting me know about it. How do you receive and view syslog on Windows? Using a tool like this? github.com/MaxBelkov/visualsyslog ThanksHix
@EdwinYip I have seen visualsyslog being used, but I prefer sending to linux (syslog-ng -> elasticsearch -> kibana) and viewing the logs from kibana which lets you do full text search on elasticsearch data from a web UI.Principalities
G
4

I'm a big fan of CodeSite, too, but if you're looking for free, how about OutputDebugString with either the Delphi IDE or DebugView from SysInternals.

Gladdy answered 27/7, 2009 at 10:48 Comment(0)
G
3

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.

Guarded answered 27/7, 2009 at 17:34 Comment(0)
D
2

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.

Dugan answered 5/9, 2013 at 16:49 Comment(2)
Link: navimatix.de/loesungen/log-server/logging-fuer-delphi-nxloggingAche
@Ache Unfortunately, it's in German. Site can be translated with Google, but not applications themselves.Quipu
A
1

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.
Ache answered 25/9, 2010 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.