From b2b7cf1df57cc475ee685f174654a34d4f122cd9 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 12 Oct 2021 11:20:59 +0100 Subject: [PATCH] journal: Expand rotate log messages in journald Make sure we always log when we rotate journals and always do so at least at INFO log level. Doing so we make sure there's always a clear reason available explaining why we rotated a journal. --- src/journal/journald-server.c | 14 +++++++++----- src/journal/journald.c | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index b8ec409cf1b..7aa734d2d36 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -811,7 +811,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n * to ensure that the entries in the journal files are strictly ordered by time, in order to ensure * bisection works correctly. */ - log_debug("Time jumped backwards, rotating."); + log_info("Time jumped backwards, rotating."); rotate = true; } else { @@ -819,8 +819,8 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n if (!f) return; - if (journal_file_rotate_suggested(f, s->max_file_usec, LOG_DEBUG)) { - log_debug("%s: Journal header limits reached or header out-of-date, rotating.", f->path); + if (journal_file_rotate_suggested(f, s->max_file_usec, LOG_INFO)) { + log_info("%s: Journal header limits reached or header out-of-date, rotating.", f->path); rotate = true; } } @@ -848,6 +848,8 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, size_t n return; } + log_info_errno(r, "Failed to write entry (%zu items, %zu bytes), rotating before retrying: %m", n, IOVEC_TOTAL_SIZE(iovec, n)); + server_rotate(s); server_vacuum(s, false); @@ -1172,6 +1174,8 @@ int server_flush_to_var(Server *s, bool require_flag_file) { goto finish; } + log_info("Rotating system journal."); + server_rotate(s); server_vacuum(s, false); @@ -1428,7 +1432,7 @@ static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo * assert(s); - log_info("Received SIGUSR2 signal from PID " PID_FMT ", as request to rotate journal.", si->ssi_pid); + log_info("Received SIGUSR2 signal from PID " PID_FMT ", as request to rotate journal, rotating.", si->ssi_pid); server_full_rotate(s); return 0; @@ -1970,7 +1974,7 @@ static int vl_method_rotate(Varlink *link, JsonVariant *parameters, VarlinkMetho if (json_variant_elements(parameters) > 0) return varlink_error_invalid_parameter(link, parameters); - log_info("Received client request to rotate journal."); + log_info("Received client request to rotate journal, rotating."); server_full_rotate(s); return varlink_reply(link, NULL); diff --git a/src/journal/journald.c b/src/journal/journald.c index 536717ce0a2..94aad05de91 100644 --- a/src/journal/journald.c +++ b/src/journal/journald.c @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) { /* The retention time is reached, so let's vacuum! */ if (server.oldest_file_usec + server.max_retention_usec < n) { - log_info("Retention time reached."); + log_info("Retention time reached, rotating."); server_rotate(&server); server_vacuum(&server, false); continue; -- 2.47.3