]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Expand rotate log messages in journald 20988/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 12 Oct 2021 10:20:59 +0000 (11:20 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 18 Oct 2021 15:48:13 +0000 (16:48 +0100)
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
src/journal/journald.c

index b8ec409cf1b863052b076817c927cc2e927954d9..7aa734d2d3641026261646a48971c40bb1492a72 100644 (file)
@@ -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);
index 536717ce0a2f3117079ac7402bf569bd63cf5c0e..94aad05de9158604dacdd80d0aee67aaba6ca9b0 100644 (file)
@@ -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;