Simple logging solution than can log across multiple processes. Main features

  • Simple logging to a file, line by line. Straightforward usage
  • Can log stack trace of all unhandled exceptions with no additional code
  • File limit on single log. Opens new file when limit is reached
  • Can safely log inside single process, across multiple threads, or even across multiple processes
SimpleLog download: Version 1.0.0 (15.12.2009)

The demo bellow shows the basic usage of SimpleLog. If you want to use Cromis.Exceptions.pas to log stack trace for all exceptions automatically, the you will need JCL. Cromis.Exceptions.pas uses JCL to obtain the stack trace. If you have trouble using the code or have any other questions, please contact me directly using the “Contact” page.

Sample usage:

procedure TfMain.btnHandledExceptionClick(Sender: TObject);
var
  DummyObject: TStringList;
begin
  try
    DummyObject.Add('Dummy string');
  except
    on E: Exception do
      SimpleLog.LogEvent('DebugLog', 'Handled exception: ' + E.Message, ltError);
  end;
end;
 
procedure TfMain.btnLogEventClick(Sender: TObject);
begin
  SimpleLog.LogEvent('DebugLog','This is warning', ltWarning);
  SimpleLog.LogEvent('DebugLog','This is error', ltError);
  SimpleLog.LogEvent('DebugLog','This is info', ltInfo);
  SimpleLog.LogEvent('DebugLog','This is hint', ltHint);
end;
 
procedure TfMain.btnUnhadnledExceptionClick(Sender: TObject);
var
  DummyObject: TStringList;
begin
  DummyObject.Add('Dummy string');
end;
 
procedure TfMain.FormCreate(Sender: TObject);
var
  RootDir: string;
begin
  RootDir := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
  SimpleLog.RegisterLog('StackLog', RootDir + 'StackLog.txt');
  SimpleLog.RegisterLog('DebugLog', RootDir + 'DebugLog.txt');
  Cromis.Exceptions.StackLogID := 'StackLog';
  SimpleLog.LockType := ltNone;
end;

Change Log

  • 1.1.0 (Breaking Change)
    • Option to log all or only the unhandled exception
    • LogExceptionWithStackTrace procedure that manually logs stack trace
    • The log file limit is now working correctly