首页 > 其他分享 >Log4Delphi日志学习

Log4Delphi日志学习

时间:2023-11-16 16:11:06浏览次数:35  
标签:end Sender Application Log4Delphi Vcl TForm2 学习 -- 日志

转载请注明出处:https://www.cnblogs.com/coder163/p/9309717.html

https://log4delphi.sourceforge.net/tutorial.html

Log4D下载:

官网地址

导入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. Compile and run the application. Click the button three times and then exit the application.
    2. You should have a log file in the tutorial folder named app.log with the following content
      DEBUG - Button Clicked
      DEBUG - Button Clicked
      DEBUG - Button Clicked

       

标签:end,Sender,Application,Log4Delphi,Vcl,TForm2,学习,--,日志
From: https://www.cnblogs.com/tulater/p/17836542.html

相关文章

  • 专家分享——CAE仿真软件学习心得
    随着科技的发展和工程设计的复杂性增加,计算机辅助工程(CAE)仿真软件成为了现代工程师不可或缺的工具。作为一名工程师,我有幸接触到了HyperWorks这一强大的CAE仿真软件,并从中获得了许多宝贵的学习心得。  首先,学习CAE仿真软件需要掌握一定的理论知识。了解有限元分析、流体力学......
  • 修改/etc/docker/daemon.json中的log-opts配置发现无效 docker 限制日志大小
    https://colobu.com/2018/10/22/no-space-left-on-device-for-docker/在/etc/docker/daemon.json中修改或添加log-opts参数"log-driver":"json-file","log-opts":{"max-size":"50m","max-file":"3"}网上很......
  • 软件设计模式学习每日总结-第四天
    第四天建造者模式:将一个复杂对象的构建和他的表 建造者模式服务于多个成员的产品,无需用户关注建造的细节。 ......
  • yzy第十次学习笔记
    第十二章学习笔记——块设备I/O和缓冲区管理块设备I/O缓冲区I/O缓冲的基本原理非常简单。文件系统使用一系列I/O缓冲区作为块设备的缓存内存。当进程试图读取(dev,blk)标识的磁盘块时。它首先在缓冲区缓存中搜索分配给磁盘块的缓冲区。如果该缓冲区存在并且包含有效数据、那么它只......
  • 《信息安全系统设计与实现》第十一周学习笔记
    块设备I/O和缓冲区管理块设备I/O缓冲区I/O缓冲的基本原理非常简单。文件系统使用一系列I/O缓冲区作为块设备的缓存内存。当进程试图读取(dev,blk)标识的磁盘块时。它首先在缓冲区缓存中搜索分配给磁盘块的缓冲区。如果该缓冲区存在并且包含有效数据、那么它只需从缓冲区中读取数据......
  • nginx 日志备份
    ·1、编辑脚本backup.sh#!/bin/bash#进入备份目录cd/data/nginx/logs/#设置备份名字newAccessLog="access`date+%Y-%m-%d`.log"newErrorLog="error`date+%Y-%m-%d`.log"#拷贝日志文件,已经在配置文件设置日志文件存放在:/data/nginx/logs/下,如果没有修改日志路径的一般在:/u......
  • 《Unix/Linux系统编程》第十二章学习笔记
    《Unix/Linux系统编程》第十二章学习笔记概念介绍块设备I/O缓冲区用来代替磁盘I/O的文件存取方法,基本原理是使用一系列的I/O缓冲区作为块设备的缓存内存。当进程试图读取(dev,blk)标识的磁盘块时,它首先在缓冲区缓存中搜索分配给磁盘块的缓冲区。如果该缓冲区存在并且包含有效......
  • nginx 日志查询
    转载:https://www.jianshu.com/p/f105fb19dd0b1、根据访问IP统计UVawk'{print$1}'access.log|sort|uniq-c|wc-l2、统计访问URL统计PVawk'{print$7}'access.log|wc-l3、查询访问最频繁的URLawk'{print$7}'access.log|sort|uniq-c|sort-n-k1-r|m......
  • goldengate add trandata显示最小附加日志already enable,但是info trandata显示disabl
    问题描述:数据库版本11.2.0.4,操作系统版本:windowsserver2012,goldengate版本12.1.2.1.0在给ogg同步表添加trandata的时候,提示supplementalredologdataisalreadyenabled。但是使用infotrandata查看的时候,却显示supplementalredologdataisdisabled。  这时通过......
  • 柯学家——珂朵莉树 学习笔记
    柯学家——珂朵莉树学习笔记珂朵莉树(ChthollyTree),又名老司机树ODT(OldDriverTree)。起源自lxl的CF896CWillem,ChthollyandSeniorious。前置知识:std::set。思想将区间用set维护,每次对一个区间进行操作的时候,就将这个区间分离(split)出来。复杂度的保证依靠推平......