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

EFileNotFoundException when log rotation is set to zero #60

Closed
luebbe opened this issue Jul 25, 2022 · 0 comments
Closed

EFileNotFoundException when log rotation is set to zero #60

luebbe opened this issue Jul 25, 2022 · 0 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone bug
Milestone

Comments

@luebbe
Copy link
Contributor

luebbe commented Jul 25, 2022

#54 triggered my memory. During testing loggerpro, I came across the following problem: If you set the log rotation to zero, like
in LoggerPro.Config in the file appender example

_Log := BuildLogWriter([
  TLoggerProFileAppender.Create(0, 5, '..\..', [],
    TLoggerProFileAppender.DEFAULT_FILENAME_FORMAT, DEFAULT_LOG_FORMAT)
 ...

an EFileNotFoundException is raised in procedure TLoggerProFileAppenderBase.RetryMove.

The simplest solution for me would be to either assert that the value is at least one or set it to Min(1, ...) in the constructor. I consider no rotation an invalid use case :)

So either:

constructor TLoggerProFileAppenderBase.Create(...
begin
  Assert(aMaxBackupFileCount > 0, 'Log rotation must be at least one.');
  ...

or

constructor TLoggerProFileAppenderBase.Create(...
begin
  ...
  fMaxBackupFileCount:= Min(1, aMaxBackupFileCount)
  ...
@danieleteti danieleteti added bug accepted Issue has been accepted and inserted in a future milestone labels Aug 3, 2022
@danieleteti danieleteti modified the milestones: milestone_1_3_0, 1_4_0 Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone bug
Projects
None yet
Development

No branches or pull requests

2 participants