Log File Names

Does the file logging (plain text/csv) provide the facility to create a new file every day/week/when a certain size is reached?

Not for now, that's something that you should handle yourself, for now.

One thing that can be done, you could create a new specific handler inheriting from TextOutputHandler, and set the filename you want. For example:

type
  TTMSLoggerDailyTextOutputHandler = class(TTMSLoggerTextOutputHandler)
  protected
    function GetOutputFile: string; override;
  end;
 
procedure TForm4.FormCreate(Sender: TObject);
begin
  TMSDefaultLogger.RegisterOutputHandlerClass(TTMSLoggerDailyTextOutputHandler,
    ['D:\trash\log\mylogfile__%date%.txt']);
end;
 
{ TTMSLoggingDailyOutputHandler }
 
function TTMSLoggerDailyTextOutputHandler.GetOutputFile: string;
begin
  Result := StringReplace(FileName, '%date%', FormatDateTime(' mm-dd-yy-hhmm', Now), [rfReplaceAll]);
end;
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.