danieleteti / loggerpro

An modern and pluggable logging framework for Delphi
Apache License 2.0
352 stars 91 forks source link

Log Rotate does nort work properly: why? #87

Closed nmm71 closed 6 months ago

nmm71 commented 6 months ago

Hi,

I used

_Log := BuildLogWriter([ TLoggerProFileAppender.Create(10, 1000, '..\proglog', [], '%0:s %1:2.2d '+ System.StrUtils.ReplaceStr(GetLoggedOnUser+' ON '+ GetRealComputerName,'.','_')+' AT '+ System.SysUtils.FormatDateTime('yyyymmddhhnnsszzz',System.SysUtils.now), DEFAULT_LOG_FORMAT)]);

and got (on a certain session) a 32 k file containig all my log-messages:

>dir My-Prog 00 nmm ON My-Comnputer AT 20240301091109558 32.475 01.03.2024 09:12 -a--

but if I use

_Log := BuildLogWriter([ TLoggerProFileAppender.Create(90, 5, '..\proglog', [], '%0:s %1:2.2d '+ System.StrUtils.ReplaceStr(GetLoggedOnUser+' ON '+ GetRealComputerName,'.','_')+' AT '+ System.SysUtils.FormatDateTime('yyyymmddhhnnsszzz',System.SysUtils.now), DEFAULT_LOG_FORMAT)]);

I got only two files

>dir My-Prog 00 nmm ON My-Comnputer AT 20240301091317671 1.727 01.03.2024 09:13 -a-- My-Prog 01 nmm ON My-Comnputer AT 20240301091317671 5.255 01.03.2024 09:13 -a--

and many log-messages are missed (I performed exactly the same session as above),

What have I done wrong?

(I used your stable version 1.4.0)

(I also tried Version 2.0 beta, but this won't compile in Delphi 10.3 (because of use of embesdded var-constructs))

Regards nmm

nmm71 commented 6 months ago

Any Idea?

danieleteti commented 6 months ago

Can you provide a reproducible test case as self-contained project?

Il lun 11 mar 2024, 18:04 nmm71 @.***> ha scritto:

Any Idea?

— Reply to this email directly, view it on GitHub https://github.com/danieleteti/loggerpro/issues/87#issuecomment-1988971090, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK4ZJBURWAJGECAPJ2MO6TYXXP2BAVCNFSM6AAAAABEBLYFQ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBYHE3TCMBZGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

nmm71 commented 6 months ago

yes.. a minimal modified version of 02_file_appender from the samples...

02_file_appender.zip

in LoggerProConfig.pas:

if you use ...TLoggerProFileAppender.Create(90, 5, ... then you get only two files 01 an d02 , one 5k, one 3k

when you klick "2000 Info": all Messages 1 to 1905 are lost.

If you use

TLoggerProFileAppender.Create(90, 10000,

you get only on file with all 2000 messages.

Regeards Mircea

luebbe commented 6 months ago

Without looking at the code: is it possible that the timestamp that you add to the file names is causing the confusion?

danieleteti commented 6 months ago

There are some problems:

Version 2 solved all these potential problems with custom filename formats. Please, try to use the version 2 (compatibility with older delphi version has been repristinated).

The only placeholders you can use in the file names are the following:

{module}: replaced with the module name {number}: replaced with the index of the log file set {tag}: log tag {pid}: replaces with the process PID (optional) to mantain logs for different runs.

This is the initialization you should use in V2

   _Log := BuildLogWriter([
    TLoggerProFileAppender.Create(90, 10000,
       'logs',
       '{module}.{number}.{tag}.log'
       )
     ]);
nmm71 commented 6 months ago

OK, Thank you for that information!