delphi 简单的日志记录


本文整理自网络,侵删。

 
procedure SaveSoldierLog(const sMessage:string);
var
  fn:string;
  sList:TStrings;
begin
  fn := ExtractFilePath(ParamStr(0))+'soft.Log';
  sList := TStringList.Create;
  try
    if FileExists(fn) then
      sList.LoadFromFile(fn);
    if sList.Count>1000 then
      sList.Clear;
    sList.Add(FormatDateTime('yyy-mm-dd hh:nn:ss',Now)+':'+sMessage);
    sList.SaveToFile(fn);
  finally
    sList.Free;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

SaveSoldierLog('日志内容');

end;

相关阅读 >>

获取 ip138 ip 地址

Delphi 2009 新增单元 character isletter、isupper、islower、isdigit、isnumber

Delphi 双击dbgrid然后得到字段里面的内容

Delphi 如何识别应用程序没有响应

Delphi firedac tfdconnection连接mysql数据库

Delphi截取技巧 lastdelimiter

Delphi ansi字符串转unicode编码

Delphi gethomepath - 获取用户程序数据目录

Delphi 扫雷外挂

Delphi firemonkey应用程序中显示时隐藏虚拟键盘

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...