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

LOGMGR-139 Add maxAge to periodic-rotating-file-handlers #336

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

y-tabata
Copy link

@y-tabata y-tabata commented Apr 1, 2021

JIRA: https://issues.redhat.com/browse/LOGMGR-139

Since #282 seems to not be proceeded, I implemented a simpler one.

Spec

  • Provide maxAge to PeriodicRotatingFileHandler (also to PeriodicSizeRotatingFileHandler).
  • PeriodicRotatingFileHandler keeps logs maxAge days.
  • Old logs are deleted based on its suffix.

@jamezp I would be happy if you give any kind of comment on this.

@y-tabata
Copy link
Author

@jamezp could you review this?

Copy link
Member

@jamezp jamezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only work in certain situations. If the suffix is ever changed, it may no longer work. If it's not rotated daily this will also not really work.

The problem is this is a tough issue to tackle correctly in the handler itself. Using a cron job or something similar is really a better safer way to do this. Having the handler make assumptions on the files it should delete based on a date can be dangerous IMO.

Comment on lines 137 to 138
if (maxAge > 0)
deleteOldFile(recordMillis);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No tabs please :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@y-tabata
Copy link
Author

@jamezp

This would only work in certain situations. If the suffix is ever changed, it may no longer work. If it's not rotated daily this will also not really work.

I know. However, if we don't have some assumptions such as using the suffix, I think there is a performance issue.
For example, if we delete logs in the specified directory according to the last modified date, we need to survey all files in the directory.

Do you mean there is more possibility to be merged than this if we introduce something like FilePurger you referred to in [1]?

[1] #282 (comment)

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

Successfully merging this pull request may close these issues.

2 participants