#1 2020-11-04 10:26:52

larand54
Member
Registered: 2018-12-25
Posts: 96

Problems with LogViewer and file rotation

If I open the logfile with the log viewer, while the program is running and produces lines to the log file, and watching it over time the log go nuts!
It seems that the log viewer holds the logfile so that log rotation can not rename the file but still copies and compresses the filecontents into the rotate-list of files.
As it can't begin with an empty file it continues to run the rotate cycle for each line that adds to the log. This will cause huge cpu and memory load.

Is there a way to avoid this and still view the log? It's too easy to forget to close the viewer and unwatched it can cause a mess.

Otherwise I really like the viewer.


Delphi-11, WIN10

Offline

#2 2020-11-04 17:21:10

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

Re: Problems with LogViewer and file rotation

This look like a bug for sure.
Can you try to find a solution, e.g. by letting the LogViewer have specific opening flags?

Offline

#3 2020-11-04 19:11:20

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

Re: Problems with LogViewer and file rotation

Yes, under Windows the problem exists from the beginning. I think it's because of a memory mapped file - so a possible solution is in memory mapped file flags. Under Linux all works as expected.

Offline

#4 2020-11-05 11:09:59

larand54
Member
Registered: 2018-12-25
Posts: 96

Re: Problems with LogViewer and file rotation

Don't know where I should set these options/flags and what choices I have?
I skimmed through the Logviewers code but didn't found anything useful.


Delphi-11, WIN10

Offline

#5 2020-11-05 20:51:49

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

Re: Problems with LogViewer and file rotation

LogViewer opens a log file using TSynLogFile = class(TMemoryMapText) from SynLog.pas
TMemoryMapText uses TMemoryMap.Map
and there is a line

F := FileOpen(aFileName,fmOpenRead or fmShareDenyNone);

Offline

Board footer

Powered by FluxBB