https://log4delphi.sourceforge.net/tutorial.html
Log4D下载:
链接:https://pan.baidu.com/s/1xnbGjvrt5jNE2WjyB9fL8Q
提取码:w91z
导入Delphi:Tool-->Options-->Environment Options--->Delphi Options--Library-->Library path
三个目录
使用
载入配置文件
菜单--->Project-->View Source
uses
Vcl.Forms,
TConfiguratorUnit, {需要引用该单元}
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
doPropertiesConfiguration('log4delphi.properties'); { 初始化,读取属性 }
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
拷贝
到exe所在目录
unit Unit2;
interface
uses
TLoggerUnit, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
TLogger.getInstance.debug('Button Clicked!');
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
TLogger.freeInstances;
end;
end.
1编译并运行该应用程序。单击该按钮三次,然后退出该应用程序。
2该目录,生成日志文件app.log