Skip to content

logger: rotate log at startup#83

Merged
kuba-moo merged 1 commit into
linux-netdev:mainfrom
matttbe:log-rotate-startup
Jul 22, 2026
Merged

logger: rotate log at startup#83
kuba-moo merged 1 commit into
linux-netdev:mainfrom
matttbe:log-rotate-startup

Conversation

@matttbe

@matttbe matttbe commented Jul 22, 2026

Copy link
Copy Markdown
Member

Before this modification, the log files were truncated at startup: the last log messages were then lost in case of restart, e.g. a service failed, restarted because the crashed seemed to be caused by a transient error, then ... arf, too late to understand why.

Now, the log files, if any and not empty, are rotated at startup. Another solution could be to modify _log_open_init() to open the log files with 'a+' to avoid the truncation. It seems cleaner to do a rotation. The drawback is that it can create many small files in case of frequent restarts, but that shouldn't be that frequent.

Before this modification, the log files were truncated at startup: the
last log messages were then lost in case of restart, e.g. a service
failed, restarted because the crashed seemed to be caused by a transient
error, then ... arf, too late to understand why.

Now, the log files, if any and not empty, are rotated at startup.
Another solution could be to modify _log_open_init() to open the log
files with 'a+' to avoid the truncation. It seems cleaner to do a
rotation. The drawback is that it can create many small files in case of
frequent restarts, but that shouldn't be that frequent.

Signed-off-by: Matthieu Baerts <matttbe@kernel.org>
@matttbe
matttbe requested a review from kuba-moo July 22, 2026 15:01
@kuba-moo
kuba-moo merged commit 5b76ec3 into linux-netdev:main Jul 22, 2026
1 check passed
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