M
M
Maxim2015-08-14 03:15:22
Delphi
Maxim, 2015-08-14 03:15:22

Which Delphi component for logging to a file would you recommend?

Interested in a component (essentially one procedure) for logging to a file, with a maximum file size limit.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
kalapanga, 2015-08-14
@kalapanga

Jedi (JVCL) has a TJvLogFile

A
Artem Kileev, 2015-08-14
@akileev

Log4D. Made by analogy with Log4j.

TLogBasicConfigurator.Configure(TLogRollingFileAppender.Create('filelog', 'file.log',
  TLogPatternLayout.Create('%d %p [%c] (%a:%t) - %m%n'), True, 'InterProcessLock',
  10 * 1024 * 1024, 3));

DefaultHierarchy.Root.Level := TLogLevel.GetLevel('all');

Z
zed, 2015-08-14
@zedxxx

mORMot TSynLog . Screenshot to attract attention - log viewer (included):
LogView01.png

M
Maxim, 2015-08-14
@ply

I analyzed what is on the Internet and realized that for my tasks it is better and easier to write a simple procedure myself

function Log_write(fname, text:string):string;
var f:TStringList;
begin
  if not DirectoryExists('logs') then CreateDir('logs');

  f:=TStringList.Create;
  try
    if FileExists('logs\'+fname+'.log') then
      f.LoadFromFile('logs\'+fname+'.log');
    f.Insert(0,DateTimeToStr(Now)+chr(9)+text);
    while f.Count>1000 do f.Delete(1001);
    f.SaveToFile('logs\'+fname+'.log');
  finally
    f.Destroy;
  end;
end;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question