[libvirt] [PATCH 2/6] Save daemon logs to libvirtd.log

Daniel P. Berrange berrange at redhat.com
Thu Mar 3 11:38:19 UTC 2011


On Thu, Mar 03, 2011 at 06:22:13PM +0800, Daniel Veillard wrote:
> 
> Depending on whether it's run as root or user, the log is saved
> in the local state dir or in $HOME/.libvirt. The file descriptor
> is kept as a global variable used by following patches.
> * daemon/libvirtd.c: add libvirtd.log as the output for logs
> 
> Signed-off-by: Daniel Veillard <veillard at redhat.com>
> ---
>  daemon/libvirtd.c |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 files changed, 85 insertions(+), 5 deletions(-)

I don't think doing this is a good idea for a couple of reasons.
First, I find that many people have already altered the libvirtd.conf
file to log to /var/log/libvirtd.log by default instead of syslog.
Second, when you have the log priority set to debug as this patch
does, the logfile can get *VERY* large *VERY* quickly. eg, when
RHEV is using libvirt it is not uncommon to see  a 300 MB of logs
generated in a mere 10 minutes, just from a fairly tightly targetted
filter like '1:qemu 1:util 1:libvirt'. If we write all logs unfiltered
at debug priority, then we will easily hit > 1 GB of data in < 10 mins.
This patch isn't allowing admins any way to turn off this extra
libvirtd.log in the cases where they are already collecting the data
via a different log output.

I agree with the idea of having a dedicated libvirtd.log file by
default though. So why don't we just change our default logging
configuration to use a logfile, instead of syslog. eg change this
block of code in libvirtd.c:

        if (godaemon) {
            if (virAsprintf(&tmp, "%d:syslog:libvirtd",
                            virLogGetDefaultPriority()) < 0)
                goto no_memory;
        } else {
            if (virAsprintf(&tmp, "%d:stderr",
                            virLogGetDefaultPriority()) < 0)
                goto no_memory;
        }

To be

        if (privileged) {
            if (virAsprintf(&tmp, "%d:file:/var/log/libvirt/libvirtd.log",
                        virLogGetDefaultPriority()) < 0)
                goto no_memory;
        } else {
           char *userdir = virGetUserDirectory(geteuid());
           if (!userdir)
              goto no_memory;
           if (virAsprintf(&tmp, "%s/.libvirt/libvirtd.log", userdir) < 0) {
              VIR_FRE(userdir);
              goto no_memory;
           }
           VIR_FRE(userdir);
        }


Thus people can just adjust 'log_debug' or 'log_filters' settings in
libvirtd.conf if they want more verbose logging.

Regards,
Daniel
--
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list