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

Addition of pgaudit.log_rotation_size option #45

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

Conversation

Nd1002
Copy link

@Nd1002 Nd1002 commented Aug 15, 2024

Good afternoon!
When using 'pgauditlogtofile', there was a need to rotate the file based on its size.
Adding log file rotation based on the size set in pgaudit.log_rotation_size. The unit of measurement is the same as in PostgreSQL's standard logging. pgaudit.log_rotation_size is only set by the user; otherwise, its functionality will be disabled.
This feature was tested in various scenarios, including with pgbench. When enabled, microseconds are added to the log file name (assuming the standard 'pgaudit-%Y-%m-%d_%H%M%S.log' template), changing it to 'pgaudit-%Y-%m-%d_%H%M%S-%ms.log', this is needed when pgaudit.log_rotation_size is set to a small value.

I would appreciate your corrections and suggestions!

@fmbiete
Copy link
Owner

fmbiete commented Aug 15, 2024

Thank you for the contribution! I like the idea of having the option of doing a rotation by size.
Some thoughts:
The filename could be something like: <pgaudit.log_filename>[.N] where N is > 0
So, if I select rotate by day and rotate after 10GB, I would have

pgaudit-20240815.log <- this always the active
pgaudit-20240815.log.1 <- first rotation after 10GB
pgaudit-20240815.log.2 <- second rotation after 20GB
pgaudit-20240815.log.3 <- third rotation after 30GB

that would require some file rename

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