#1 2019-07-26 10:52:41

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,539
Website

Force rotation in TSynLog

In pull #225 I try to implement a manual log rotation feature.

I'm plane to use it in a SIGHUP signal handler to release a log file descriptor. By Unix convention in response to SIGHUP signal daemon should reload configuration and reopen all opened files.

This is VERY useful on a big production in case we need to get a full log for a some period of time. In my case if I enable all log levels I got > 100Mb of logs per MINUTE, so having it always ON is very expensive. So I implement a SIGHUP handler what load a new logLevels form a daemon config and call TSynLog.ForceRotation to create a new log file with a new log levels.

As a side effect with a combination of custom OnRotate handler + ForceRotation we can use a Unix logrotate for complex log rotation scenarios (see short explanation why handle SIGHUP for logrotate)

Last edited by mpv (2019-07-26 10:56:36)

Offline

#2 2019-07-26 12:53:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Force rotation in TSynLog

Offline

#3 2019-07-26 13:33:40

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: Force rotation in TSynLog

Nice feature!


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB