]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
daemon: Limit default log level to journald to VIR_LOG_INFO
authorPeter Krempa <pkrempa@redhat.com>
Tue, 12 Aug 2014 14:10:39 +0000 (16:10 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Aug 2014 08:29:05 +0000 (10:29 +0200)
Libvirt is really chatty when the DEBUG log level is enabled. When a
host uses journald we'd enable debug logging to journald when only
specifying the debug log level. As journald may employ rate throttling
this would lock up the daemon until it's able to flush all debug
messages.

This patch changes the default log level to VIR_LOG_INFO when using the
default (unconfigured) log output to journald.

To still allow debug logging to journald the user now has to explicitly
specify journald as a log output with priority 1 in the "log_outputs"
configuration option. This patch also changes the config file template
to be explicit about this change and notify the user about the possible
consequence of debug logging into journald.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1121955

daemon/libvirtd.c
daemon/libvirtd.conf

index 946081a486a4be90c0d316f5e0ad0af5f9504b10..a1f64adf7e962a51d9c01180e343fbaecda0e8a3 100644 (file)
@@ -678,7 +678,14 @@ daemonSetupLogging(struct daemonConfig *config,
         (godaemon || !isatty(STDIN_FILENO))) {
         char *tmp;
         if (access("/run/systemd/journal/socket", W_OK) >= 0) {
-            if (virAsprintf(&tmp, "%d:journald", virLogGetDefaultPriority()) < 0)
+            virLogPriority priority = virLogGetDefaultPriority();
+
+            /* By default we don't want to log too much stuff into journald as
+             * it may employ rate limiting and thus block libvirt execution. */
+            if (priority == VIR_LOG_DEBUG)
+                priority = VIR_LOG_INFO;
+
+            if (virAsprintf(&tmp, "%d:journald", priority) < 0)
                 goto error;
             virLogParseOutputs(tmp);
             VIR_FREE(tmp);
index c73423f0ddaaac0ee0f3f165db48145863649be5..2d80274edcf01e260a084faa03ed107c9455c735 100644 (file)
 
 # Logging level: 4 errors, 3 warnings, 2 information, 1 debug
 # basically 1 will log everything possible
+# Note: Journald may employ rate limiting of the messages logged
+# and thus lock up the libvirt daemon. To use the debug level with
+# journald you have to specify it explicitly in 'log_outputs', otherwise
+# only information level messages will be logged.
 #log_level = 3
 
 # Logging filters: