mirror of
https://github.com/decke/smtprelay.git
synced 2026-04-25 04:45:52 +03:00
[GH-ISSUE #228] Feature request: Allow log rotation #45
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/smtprelay#45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Steltek on GitHub (Aug 1, 2025).
Original GitHub issue: https://github.com/decke/smtprelay/issues/228
Originally assigned to: @decke on GitHub.
Request:
It would be nice to be able to rotate the log so that it doesn't grow infinitely. Right now this is prevented on Windows as the logs are being opened with an exclusive lock, preventing the file from being renamed while smtprelay is running. (Programmatically stopping smtprelay to rotate the log might cause whatever message is in flight to get lost/dropped.)
Possible implementations:
A. Change smtprelay to open the log non-exclusively and handle the case of the file potentially vanishing by re-creating it.
or
B. Add log rotation directly in smtprelay, possibly configurable in the .ini.
The lumberjack module could be useful for that: https://pkg.go.dev/gopkg.in/natefinch/lumberjack.v2?utm_source=godoc
Example code (vibe-coded so may not be correct at all):
@decke commented on GitHub (Aug 2, 2025):
I agree that logfile rotation is essential and needs to function properly.
My issue with option A is that it should already work - though probably not on Windows. As for option B, lumberjack is no longer maintained. However, there appears to be a fork called timberjack that might be a better alternative.
I am currently working on a replacement of logrus with zerolog. Logrus is becoming obsolete and relies on some unmaintained projects. I already have a partially completed patch for this, but it still needs some refinement. I will check logfile rotation as well when I have time to work on it.