Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Rotate does nort work properly: why? #87

Closed
nmm71 opened this issue Mar 1, 2024 · 6 comments
Closed

Log Rotate does nort work properly: why? #87

nmm71 opened this issue Mar 1, 2024 · 6 comments
Assignees
Milestone

Comments

@nmm71
Copy link

nmm71 commented Mar 1, 2024

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
Copy link
Author

nmm71 commented Mar 11, 2024

Any Idea?

@danieleteti
Copy link
Owner

danieleteti commented Mar 11, 2024 via email

@nmm71
Copy link
Author

nmm71 commented Mar 12, 2024

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
Copy link
Contributor

luebbe commented Mar 12, 2024

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

@danieleteti
Copy link
Owner

danieleteti commented Mar 12, 2024

There are some problems:

  • to make the log rotations happens, filename cannot depends by date/time
  • the generated filenames seems to collide becaouse the format is not correct

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
Copy link
Author

nmm71 commented Mar 12, 2024

OK, Thank you for that information!

@danieleteti danieleteti added this to the 2_0_0 milestone Mar 12, 2024
@danieleteti danieleteti self-assigned this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants